1、下载MySQL
https://downloads.mysql.com/archives/community/
2、下载完毕后,上传到Centos,解压
bash
tar -xf mysql-8.0.33-1.el7.x86_64.rpm-bundle.tar
3、逐条执行安装命令
bash
rpm -ivh mysql-community-common-8.0.33-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-plugins-8.0.33-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-8.0.33-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-8.0.33-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-plugins-8.0.33-1.el7.x86_64.rpm
rpm -ivh mysql-community-icu-data-files-8.0.33-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-8.0.33-1.el7.x86_64.rpm
mysqld --initialize --user=mysql
systemctl status mysqld
systemctl start mysqld
systemctl status mysqld
4、查看临时密码
bash
cat /var/log/mysqld.log
5、修改mysql的root密码
bash
alter user 'root'@'localhost' identified by 'xxxxxx'
执行完后,重新登录MySQL
bash
quit
6、允许远程登录
bash
mysql -uroot -p
bash
use mysql;
select host from user where user='root';
update user set host = '%' where user ='root';
更新配置
bash
flush privileges;