安装依赖
yum install libaio wget -y
检查MYSQL是否已安装
yum list installed | grep mysql
如果有先卸载
# 格式 yum -y remove [包名]
yum -y remove mysql-libs.x86_64
下载MySQL官网的仓库文件
cd /tmp wget http://repo.mysql.com/mysql80-community-release-el7-1.noarch.rpm yum localinstall mysql80-community-release-el7-1.noarch.rpm
验证仓库是否添加成功
yum repolist enabled | grep "mysql.*-community.*"
安装MySQL
yum install mysql-community-server -y
时MySQL 安装完成,它包含了
mysql-community-server、mysql-community-client
mysql-community-common、mysql-community-libs 四个包
执行
rpm -qi mysql-community-server.x86_64 0:8.0.16-2.el7
然后
whereis mysql
可以看到MySQL 的安装目录是 /usr/bin/
启动服务
systemctl start mysqld systemctl enable mysqld systemctl status mysqld
查找初始密码
cat /var/log/mysqld.log | grep password
mysql -uroot -p
mysql> ALTER USER 'root'@'%' IDENTIFIED BY 'hbV0pOO!(Z#R' PASSWORD EXPIRE NEVER;
mysql> ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'hbV0pOO!(Z#R';
mysql> FLUSH PRIVILEGES;
mysql> alter user 'root'@'%' identified by 'hbV0pOO!(Z#R';
测试连接