Host xxxx is not allowed to connect to this MySQL server

拈花ヽ惹草 提交于 2019-12-02 11:11:03

问题


Well, after reading topics with the same name without success I feel forced to ask again and show you my scenario:

I am on a Kali Linux machine, my mysql config file (/etc/my.cnf) is setup this way:

bind-address = 172.16.1.228

I reset the service I can't enter neither remotely nor localy, I got this 2 errors depending on how I access:

root@Adkadon:~# mysql -u root -p -h 172.16.1.228
Enter password: 
ERROR 1130 (HY000): Host 'Adkadon' is not allowed to connect to this MySQL server

mysql -u root -p -h 127.0.0.1
Enter password: 
ERROR 2003 (HY000): Can't connect to MySQL server on '127.0.0.1' (111)

Note that without the -h 127.0.0.1 I have never been allowed to access.

So, I change the my.cnf and set bind-address to 0.0.0.0.

I access this way: mysql -u root -p -h 127.0.0.1, I do the following:

GRANT ALL PRIVILEGES ON *.* TO root@172.16.1.228 BY ‘root‘ WITH GRANT OPTION;

Again change bind-address to 172.16.1.228 and no success.

This is the output of SELECT user,host FROM user; inside the database:

root             | 127.0.0.1    |
| root             | 172.1.16.228 |
| root             | ::1          |
| debian-sys-maint | localhost    |
| root             | localhost    |
| root             | repo   

I don't know what do to, any idea¿? Thank you very much


回答1:


If I guess right, 172.1.16.228 is your IP of mysql server . 'Adkadon' is the host where you try to access mysql from.

If that is the case, get the IP address of Adkadon (ifconfig)

Say if 172.1.16.xxx is your host IP, then in my.cnf mention

bind-address = 172.16.1.xxx This indicates connections are allowed only from 172.16.1.xxx

Create a user root@172.16.1.xxx

And for connecting to mysql , use command

mysql -u root -p -h 172.1.16.228

Please note, -h 172.1.16.228 indicates where to connect to, not where it is connecting from.

Does it solve your problem? Or am I missing something from your question?



来源:https://stackoverflow.com/questions/29672480/host-xxxx-is-not-allowed-to-connect-to-this-mysql-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!