完美解决mysql客户端授权后连接失败的问题
在本地(192.168.1.152)部署好mysql环境,授权远程客户机192.168.1.%连接本机的mysql,在iptables防火墙也已开通3306端口。
如下:
mysql> select host,user,password from mysql.user;
+--------------+-----------------+---------------------------------------------------------+
| host | user | password |
+--------------+-----------------+----------------------------------------------------------+
| localhost | root | |
| fdm1 | root | |
| 127.0.0.1 | root | |
| localhost | | |
| fdm1 | | |
| 192.168.1.% | db_hqsb | *dfc9dc16b13651a95ecec3a26e07d244431b55c9 |
| 192.168.1.% | db_ro_hqsb | *2c0b0dd50595bb40879110437beef026d019dfb7 |
| 192.168.1.% | db_jkhwuser | *2c0b0dd50595bb40879110437beef026d019dfb7 |
| 192.168.1.25| slave | *ee52b8eacb3ccd13624273ad6b5cda52b9b53eb7 |
| 192.168.1.% | tech_db_user | *6053e57c7b61043dc2c6b4e3291d5f61ccc23f5c |
| 192.168.1.% | game_db_user| *05ea4d71c9a1273ecf3e24e6323f7175ae45c366 |
| localhost | zabbix | *6bb4837eb74329105ee4568dda7dc67ed2ca2ad9 |
+---------------+---------------+------------------------------------------------------------+
问题:
在客户机(比如192.168.1.20)上远程连接上面192.168.1.152机器的mysql,连接失败!
[root@huanqiu ~]# mysql -udb_ro_hqsb -h 192.168.1.152 -pmhxzkhl0802xqsjdb error 1130 (hy000): host '192.168.1.20' is not allowed to connect to this mysql server
解决:
是由于192.168.1.152的mysql里“host为localhost,user和password为空”这条语句导致的,删除这条即可解决问题!
mysql> delete from mysql.user where host="localhost" and user="";
query ok, 1 row affected (0.00 sec)
mysql> flush privileges;
query ok, 0 rows affected (0.00 sec)
这样,授权连接的客户机就能成功连接了!
[root@huanqiu ~]# mysql -uxqsj_db_ro_user -h 192.168.1.152 -pmhxzkhl0802xqsjdb welcome to the mysql monitor. commands end with ; or \g. your mysql connection id is 28 server version: 5.1.73 source distribution copyright (c) 2000, 2013, oracle and/or its affiliates. all rights reserved. oracle is a registered trademark of oracle corporation and/or its affiliates. other names may be trademarks of their respective owners. type 'help;' or '\h' for help. type '\c' to clear the current input statement. mysql>
以上这篇完美解决mysql客户端授权后连接失败的问题就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。
推荐阅读
-
完美解决mysql客户端授权后连接失败的问题
-
完美解决,不用重装:MySQL启动失败提示:本地计算机上的Mysql服务启动后停止
-
完美解决MySQL通过localhost无法连接数据库的问题
-
完美解决mysql客户端授权后连接失败的问题
-
完美解决mysql启动后随即关闭的问题(ibdata1文件损坏导致)
-
完美解决MySQL通过localhost无法连接数据库的问题
-
win7系统安装2个mysql版本后连接不上数据库的问题如何解决?
-
刨根问底,完美解决Django2版本连接MySQL报错的问题
-
IDEA链接MySQL报错08001和连接成功后不显示表的问题及解决方法
-
解决Navicat for Mysql连接报错1251的问题(连接失败)