MySQLdb 1130 error: not getting the correct server IP address

I am trying to connect to mysqldb through a python script. I changed the binding address in my.cnf to "192.168.56.101", which is my ip server.

import MySQLdb db = MySQLdb.connect(host='192.168.56.101', user='root', passwd='pass', db='python') 

The above code gives me the following error.

 _mysql_exceptions.OperationalError: (1130, "Host '192.168.56.1' is not allowed to connect to this MySQL server") 

He took my ip '192.168.56.101' as '192.168.56.1'? Also I tried this:

 mysql -u nilani -p pass -h 192.168.56.101 

He also gives the same error

 ERROR 1130 (HY000): Host '192.168.56.1' is not allowed to connect to this MySQL serve 

Why can't he correctly identify my ip?

+4
source share
1 answer

This is a lack of server-side permissions.

MySQL does not allow root users to connect from other computers on the network. IP 192.168.56.1 is probably your own IP address.

To create a user that can register on other computers, refer to this question: Host 'xxx.xx.xxx.xxx' is not allowed to connect to this MySQL server

This includes creating a separate user for the local host and remote access to the host on the server (taken from a related question):

 mysql> CREATE USER 'monty'@'localhost' IDENTIFIED BY 'some_pass'; mysql> GRANT ALL PRIVILEGES ON *.* TO 'monty'@'localhost' -> WITH GRANT OPTION; mysql> CREATE USER 'monty'@'%' IDENTIFIED BY 'some_pass'; mysql> GRANT ALL PRIVILEGES ON *.* TO 'monty'@'%' -> WITH GRANT OPTION; 
+1
source

Source: https://habr.com/ru/post/1492350/


All Articles