简体   繁体   中英

Host xxxx is not allowed to connect to this MySQL server

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

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?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM