MySQL安装之CentOS 7下使用rpm包安装8.0版本
一、删除已有mysql
rpm -qa | grep mysql 查找是否存在已安装的mysql
yum remove mysql-community-common-x.x.xx-1.el7.x86_64 如果找到,则依次卸载全部安装包
find / -name *mysql* 查找mysql的残余文件
rm -rf /usr/lib64/mysql 如果找到,则依次删除所有残余文件
二、安装mysql服务
1、下载地址:https://downloads.mysql.com/archives/community/,本文选择8.0.20,依次下载、安装如下文件
rpm -ivh mysql-community-common-8.0.20-1.el7.x86_64.rpm rpm -ivh mysql-community-libs-8.0.20-1.el7.x86_64.rpm rpm -ivh mysql-community-client-8.0.20-1.el7.x86_64.rpm rpm -ivh mysql-community-server-8.0.20-1.el7.x86_64.rpm
2、启动mysql服务
systemctl start mysqld
3、查看临时密码
cat /var/log/mysqld.log | grep password
4、使用临时密码登录
mysql -uroot -p
5、修改临时密码为自己指定密码
alter user 'root'@'localhost' identified by 'shenL1234!';
6、创建远程访问用户和密码、并赋予权限
create user 'root'@'%' identified with mysql_native_password by 'shenL1234!'; 创建用户并指定密码 grant all privileges on *.* to 'root'@'%' with grant option; 授权 flush privileges; 刷新权限