目录
1.wget安装
yum install -y wget
2.下载官方rpm包
wget -i -c https://repo.mysql.com/mysql80-community-release-el7-9.noarch.rpm
Index of /232905 这个网址是仓库地址
3.安装
yum install -y mysql80-community-release-el7-1.noarch.rpm
yum install -y mysql-community-server --nogpgcheck
--nogpgcheck是解决公钥没有安装问题
4.设置大小写敏感
vim /etc/my.cnf再后面加上:
lower_case_table_names=1(1是不敏感,0是敏感)
5.启动MySQL服务
systemctl start mysqld.service
systemctl status mysqld.service
6.查看原始密码
grep 'password' /var/log/mysqld.log
7.登录进去后修改密码
alter user 'root'@'localhost' identified by '新密码';
密码过于简单会报错,可以先改密码为:Root_root123,然后通过设置
set global validate_password.policy=LOW;
set global validate_password.length=6;
在更改密码为123456,现在可以正常使用了
mysql -uroot -p123456
8.设置远程访问
systemctl start firewalld.service开启防火墙
firewall-cmd --permanent --zone=public --add-port=3306/tcp开放3306端口
firewall-cmd --reload刷新防火墙
如果是关闭防火墙的情况下,就不用上面步骤。
编辑vim /etc/my.cnf文件,添加如下行,用来更改密码加密认证方式
default-authentication-plugin=mysql_native_password
进入MySQL数据库,切换到mysql库,use mysql;
查表:select host,user,authentication_string,plugin from user;
发现root用户主机不是%,修改成%
update user set host = '%' where user = 'root';
flush privileges;刷新权限
到此可以远程操控了。