1. 3306端口是不是没有打开?

使用nestat命令查看3306端口状态:

~# netstat -an | grep 3306

tcp        0      0 127.0.0.1:3306          0.0.0.0:*               LISTEN

从结果可以看出3306端口只是在IP 127.0.0.1上监听,所以拒绝了其他IP的访问。

解决方法:修改/etc/mysql/my.cnf文件。打开文件,找到下面内容:

# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address  = 127.0.0.1

把上面这一行注释掉或者把127.0.0.1换成合适的IP,建议注释掉。

重新启动后,重新使用netstat检测:

~# netstat -an | grep 3306
tcp        0      0 0.0.0.0:3306            0.0.0.0:*               LISTEN

2. 问题解决了吗?

现在使用下面命令测试

 ~# mysql -h 10.1.1.2 -u root -p
Enter password:
ERROR 1130 (00000): Host 'B0324-Desktop.local' is not allowed to connect to this MySQL server

结果出乎意料,还是不行。

解决方法:原来还需要把用户权限分配各远程用户。

登录到mysql服务器,使用grant命令分配权限

mysql> grant all on database_name.* to user_name@'%' identified by 'user_password';

其中database_name、user_name和user_password根据实际情况设置。

完成后使用mysql命令连接,提示成功,为了确保正确可以再远程登陆测试一下。

转自:http://blog.csdn.net/mydeman/article/details/3847695

相关文章:

  • 2021-04-04
  • 2022-01-10
  • 2021-09-28
  • 2021-10-31
  • 2022-03-01
  • 2021-10-27
  • 2021-05-08
猜你喜欢
  • 2021-11-15
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-14
  • 2021-06-16
  • 2022-01-13
相关资源
相似解决方案