mysql远程连接
1,问题截图
2,确认防火墙已关闭
1)直接关闭防火墙
[[email protected] ~]# firewall-cmd --state
running
[[email protected] ~]# systemctl stop firewalld
[[email protected] ~]# firewall-cmd --state
not running
2)开放对应端口3306
[[email protected] ~]# firewall-cmd --permanent --add-port=3306/tcp
success
[[email protected] ~]# systemctl restart firewalld
[[email protected] ~]# netstat -an|grep 3306
tcp6 0 0 :::3306 :::* LISTEN
3,更改对应字段
mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> update user set host = ’%’ where user = ’root’;
ERROR 1054 (42S22): Unknown column '’root’' in 'where clause'
更改字段时出现错误,查了许久发现是root密码设置简单,而系统默认validate_password_policy为1,需修改为更低级别。(参照https://www.cnblogs.com/ivictor/p/5142809.html)
mysql> set global validate_password_policy=0;
Query OK, 0 rows affected (0.00 sec)
mysql> update user set host = '%' where user = 'root';
Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> select host,user,authentication_string from user;
+-----------+---------------+-------------------------------------------+
| host | user | authentication_string |
+-----------+---------------+-------------------------------------------+
| % | root | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |
| localhost | mysql.session | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |
| localhost | mysql.sys | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |
+-----------+---------------+-------------------------------------------+
3,测试结果