Remote MYSQL Access

Introduction:

By default, MySQL does not allow remote clients to connect to the MySQL database. If you are trying to gain access to your server’s MYSQL database remotely, it is prominent that you will be getting a response similar to this:

ERROR 1130: Host is not allowed to connect to this MySQL server

Example:

$ mysql -h XXX.168.X.8 -u root -p
Enter password:
ERROR 1130: Host 'xxx.xx.x.x' is not allowed to connect to this MySQL server

Solution:

To overcome this error, you can allow a specific client ip-address (Static Ip) to access the MySQL database running on a server. You should execute the following command on the server that is running the MySQL database:

$ mysql -u root -p
Enter password:

mysql> use mysql

mysql> GRANT ALL ON *.* to root@'XXX.XXX.X.X' IDENTIFIED BY 'your-root-password'; 

mysql> FLUSH PRIVILEGES;

Replace ‘XXX.XXX.X.X’ in the above example with your static-Ip and your Root password in place of ‘your-root-password’.

Note: This will only work if you are running your internet on a static-Ip based service.

A static IP address is a number that is assigned to a computer by an Internet service provider (ISP) to be its permanent address on the Internet..

The execution of the above commands will grant access to one specific static Ip, using which MYSQL can be accessed remotely.

Also, update firewall rules to make sure port# 3306 in the Ip Table is open on the server that is running the mysql database.

 

Add A Comment