Centos7安装Mysql8
安装MySQL rpm源
打开https://dev.mysql.com/downloads/repo/yum/
选择对应安装包
拼接下载地址,并且运行下载
wget http://dev.mysql.com/get/mysql80-community-release-el7-10.noarch.rpm
安装源
rpm -ivh mysql80-community-release-el7-7.noarch.rpm
yum安装Mysql
yum install mysql-community-server
检查是否成功,输出类似以下内容,表示安装完成
[root@monitor grafana]# rpm -qa | grep mysql
mysql80-community-release-el7-10.noarch
mysql-community-client-plugins-8.0.34-1.el7.x86_64
mysql-community-server-8.0.34-1.el7.x86_64
mysql-community-common-8.0.34-1.el7.x86_64
mysql-community-client-8.0.34-1.el7.x86_64
mysql-community-icu-data-files-8.0.34-1.el7.x86_64
mysql-community-devel-8.0.34-1.el7.x86_64
mysql-community-libs-8.0.34-1.el7.x86_64
启动Mysql
systemctl start mysqld && systemctl enable mysqld && systemctl status mysqld
查看初始化密码
grep 'temporary password' /var/log/mysqld.log
登录
mysql -u root -p'密码内容'
Mysql在第一次启动的时候,需初始化一个密码然后退出
ALTER USER 'root'@'localhost' IDENTIFIED BY 'Root_123';
exit
重新登陆Mysql
mysql -u root -p'Root_123'
安装密码验证插件,修改密码校验策略
install plugin validate_password soname 'validate_password.so';
查看验证策略的键、值信息
mysql> SHOW VARIABLES LIKE 'validate_password%';
+-------------------------------------------------+--------+
| Variable_name | Value |
+-------------------------------------------------+--------+
| validate_password.changed_characters_percentage | 0 |
| validate_password.check_user_name | ON |
| validate_password.dictionary_file | |
| validate_password.length | 8 |
| validate_password.mixed_case_count | 1 |
| validate_password.number_count | 1 |
| validate_password.policy | MEDIUM |
| validate_password.special_char_count | 1 |
| validate_password_check_user_name | ON |
| validate_password_dictionary_file | |
| validate_password_length | 8 |
| validate_password_mixed_case_count | 1 |
| validate_password_number_count | 1 |
| validate_password_policy | MEDIUM |
| validate_password_special_char_count | 1 |
+-------------------------------------------------+--------+
15 rows in set (0.00 sec)
修改密码策略和密码长度
set global validate.password_policy=0;
set global validate_password_policy=0;
set global validate.password_length=16;
set global validate_password_length=16;
修改最终的密码
ALTER USER 'root'@'localhost' IDENTIFIED BY 'djxnwislxnghtrzi';