连接centos虚拟机上的mysql
1、关闭防火墙
systemctl stop firewalld
systemctl disable firewalld
2、修改mysql连接用户的配置
mysql -uroot -p
输入mysql 密码
第一次进入需要改动密码。
若是自己局域网部署测试的话, 密码过于简单会提示修改不成功,需要 设置下密码规则
值 |
参数解释 |
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 |
validate_password_special_char_count |
密码至少要包含的特殊字符数。 |
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,所以刚开始设置的密码必须符合长度,且必须含有数字,小写或大写字母,特殊字符。
mysql> set global validate_password_policy=0;
Query OK, 0 rows affected (0.05 sec)
mysql>
mysql>
mysql> set global validate_password_mixed_case_count=0;
Query OK, 0 rows affected (0.00 sec)
mysql> set global validate_password_number_count=3;
Query OK, 0 rows affected (0.00 sec)
mysql> set global validate_password_special_char_count=0;
Query OK, 0 rows affected (0.00 sec)
mysql> set global validate_password_length=3;
Query OK, 0 rows affected (0.00 sec)
mysql> SHOW VARIABLES LIKE 'validate_password%';
+--------------------------------------+-------+
| Variable_name | Value |
+--------------------------------------+-------+
| validate_password_dictionary_file | |
| validate_password_length | 3 |
| validate_password_mixed_case_count | 0 |
| validate_password_number_count | 3 |
| validate_password_policy | LOW |
| validate_password_special_char_count | 0 |
+--------------------------------------+-------+
6 rows in set (0.00 sec)
修改完后, 修改数据库的用户关系
use mysql
update user set host = '%' where user = 'root';
或是
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
再执行刷新权限
flush privileges;