1.安装mysql依赖perl net-tools
?yum install perl net-tools -y
2.卸载mariadb(linux 默认安装mariadb)
rpm -qa | grep mariadb? ? ? #查询安装文件目录
rpm -e --nodeps 文件? ? ? ? ?#卸载文件 --nodeps 忽略依赖关系
3.安装mysql
?tar -xvf mysql-8.0.18-1.el7.x86_64.rpm-bundle.tar
?解压出来的包如上图,依次安装,顺序不能乱
- rpm -ivh mysql-community-common-8.0.18-1.el7.x86_64.rpm?
- rpm -ivh mysql-community-libs-8.0.18-1.el7.x86_64.rpm
- rpm -ivh mysql-community-client-8.0.18-1.el7.x86_64.rpm
- rpm -ivh mysql-community-server-8.0.18-1.el7.x86_64.rpm
4.启动mysql
systemctl start mysqld
5.查找密码并登录mysql
cat /var/log/mysqld.log | grep password
红色框内为初始密码
mysql? -u root -p
登录修改密码
ALTER user 'root'@'localhost' IDENTIFIED BY '123456'; #123456为密码
flush privileges;
修改mysql链接地址
use mysql;
update user set host='%' where user = 'root';
commit;
exit;
重启mysql
systemctl restart mysqld
|