1、添加MySQL的yum仓库
下载地址:
下载后,执行如下命令:
shell> sudo rpm -Uvh mysql80-community-release-el6-n.noarch.rpm
2、安装mysql
shell> sudo yum install mysql-community-server
3、启动mysql
启动mysql
shell> sudo systemctl start mysqld.service
查看mysql状态
shell> sudo systemctl status mysqld.service
4、查询root密码
shell> sudo grep 'temporary password' /var/log/mysqld.log
登陆,重新设置密码
shell> mysql -uroot -pmysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';
5、密码错误
如果报错,密码不符合当前设置的强度规则
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
执行如下命令,查看密码规则
mysql> SHOW VARIABLES LIKE 'validate_password%'; +--------------------------------------+--------+| Variable_name | Value |+--------------------------------------+--------+| 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 |+--------------------------------------+--------+7 rows in set (0.01 sec)
参数解释:
validate_password_dictionary_file
插件用于验证密码强度的字典文件路径。
validate_password_length
密码最小长度,参数默认为8,它有最小值的限制,最小值为:validate_password_number_count + validate_password_special_char_count + (2 * validate_password_mixed_case_count)
validate_password_mixed_case_count
密码至少要包含的小写字母个数和大写字母个数。validate_password_number_count
密码至少要包含的数字个数。validate_password_policy
密码强度检查等级,0/LOW、1/MEDIUM、2/STRONG。有以下取值:Policy | Tests Performed |
---|---|
0 or LOW | Length |
1 or MEDIUM | Length; numeric, lowercase/uppercase, and special characters |
2 or STRONG | Length; numeric, lowercase/uppercase, and special characters; dictionary file |
默认是1,即MEDIUM,所以刚开始设置的密码必须符合长度,且必须含有数字,小写或大写字母,特殊字符。
validate_password_special_char_count
密码至少要包含的特殊字符数。