解决不能访问远程mysql的问题

时间:2023-03-09 04:58:02
解决不能访问远程mysql的问题

一般是没有给用户访问权限

给用户test_user授权,让他可以从外部登陆和本地登陆
注意:@左边是用户名,右边是域名、IP和%,表示可以访问mysql的域名和IP,%表示外部任何地址都能访问。

mysql> grant all privileges on *.* to 'test_user'@'localhost' identified by 'test_user';
Query OK, 0 rows affected (0.00 sec)
mysql> grant all privileges on *.* to 'test_user'@'%' identified by 'test_user';
Query OK, 0 rows affected (0.00 sec)
mysql> select user,host,password from mysql.user;