1.下载mysql-8.0.25-1.el7.x86_64.rpm-bundle
2.卸载mariadb
3.安装
yum localinstall mysql-community-common-8.0.25-1.el7.x86_64.rpm yum localinstall mysql-community-client-plugins-8.0.25-1.el7.x86_64.rpm yum localinstall mysql-community-libs-8.0.25-1.el7.x86_64.rpm yum localinstall mysql-community-client-8.0.25-1.el7.x86_64.rpm yum localinstall mysql-community-server-8.0.25-1.el7.x86_64.rpm
4.初始化
mysqld --initialize
chown
mysql:mysql
/var/lib/mysql
-R 授权
5.启动
systemctl start mysqld 开启mysql服务
systemctl status mysqld 查看mysql 状态
6.通过cat /var/log/mysqld.log | grep password 查看root初始密码
7.使用root用户登录mysql ,并修改root用户密码
mysql -u root -p #回车之后输入前面的初始密码也就是 上面查看的初始密码(填自己的密码) 然后输入alter user "root"@"localhost" identified by "123456"; #修改密码(Aa123456 为自己设的密码可随意变换)
8.通过以下命令,进行远程访问的授权
create user 'root'@'%' identified with mysql_native_password by 'Aa23456'; grant all privileges on *.* to 'root'@'%' with grant option; flush privileges; #立即生效
9.远程连接