1. 添加 Yum 包
wget https:
//dev
.mysql.com
/get/mysql80-community-release-el7-1
.noarch.rpm
rpm -ivh mysql80-community-release-el7-1.noarch.rpm
2. 安装 MySQL
yum -y
install
mysql-community-server
systemctl start mysqld
3. 修改密码
MySQL 安装过程中会为 root 用户生成一个临时密码,保存在 /var/log/mysqld.log 中。通过以下命令查看:
sudo grep ‘temporary password‘ /var/log/mysqld.log
mysql -u root -p
ALTER USER
‘root‘
@
‘localhost‘
IDENTIFIED BY
‘your passowrd‘
;
密码强度要求是:不少于12字符,必须包含大写字母、小写字母、数字和特殊字符。
4 创建root远程连接
CREATE USER ‘root‘@‘%‘ IDENTIFIED BY ‘root‘;
GRANT ALL PRIVILEGES ON *.* TO ‘root‘@‘%‘ WITH GRANT OPTION;
root 用户默认的密码加密方式是:caching_sha2_password;而很多图形客户端工具可能还不支持这种加密认证方式,连接的时候就会报错 。通过以下命令重新修改密码:
ALTER USER ‘root‘@‘%‘ IDENTIFIED WITH mysql_native_password BY ‘[email protected]‘;