29 C
Jaipur
Sunday, October 18, 2020

Host is not allowed to connect to this MySQL server

Must read

Packers vs Buccaneers live stream: how to watch NFL week 6 online from anywhere now

This could be tasty. Amazingly, the 36-year-old Aaron Rodgers and 43-year-old Tom Brady have only ever faced each other twice before - in 2014...

Jets vs Dolphins live stream: how to watch NFL week 6 online from anywhere now

The Jets are going to Miami this weekend, where they'll be trying to wrestle their first win of the season from the 2-3 Dolphins....

7 Best Free Case Converter Online|Title Capitalization Tool In 2020

While it’s possible to change case of a couple of sentences manually, doing the same for long paragraphs can be burdensome. This is where...

PopSockets Is Developing New MagSafe-Compatible Grips

With the launch of the newest iPhone 12 series, Apple revived the MagSafe charging system for its mobile devices. Although there is an array...

In this quick article, you will learn how to solve the “ERROR 1130 (HY000): Host x.x.x.x is not allowed to connect to this MySQL server” error in MySQL/MariaDB database deployment on a Linux system. This is one of the common remote database connection errors encountered by users.

Test Environment:

  • Application Server IP: 10.24.96.5
  • Database Server IP: 10.24.96.6

We encountered the error while testing database connection from one of our app servers to a database server, using the mysql client as shown.

# mysql -u database_username -p -h 10.24.96.6
MySQL Remote Database Connection Error

The error indicates that the host 10.24.96.5 that the database user is connecting from is not allowed to connect to the MySQL server. In this case, we have to make some changes to the database server to enable the user to connect remotely.

On the database server, we have to check the host the user above is allowed to connect from.

# mysql -u root -p

Run the following SQL commands to check the user’s host:

MariaDB [(none)]> SELECT host FROM mysql.user WHERE user = "database_username";
Check MySQL User Host
Check MySQL User Host

From the output of the command, the user is only allowed to connect to the database server from the localhost. So, we need to update the user’s hosts as follows.

Run the following GRANT command to enable MySQL access for the remote user from a remote host. Make sure to replace “10.24.96.6” with the IP address of the remote system, and “database_password” to the password that you want “database_username” to use:

MariaDB [(none)]> GRANT ALL ON database_name.* to 'database_username'@'10.24.96.5' IDENTIFIED BY 'database_password';
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> SELECT host FROM mysql.user WHERE user = "database_username";
Enable Remote MySQL Database Access to User from Remote Host
Enable Remote MySQL Database Access to User from Remote Host

To give a user remote access from all host on a network, use the syntax below:

MariaDB [(none)]> GRANT ALL ON database_name.* to 'database_username'@'10.24.96.%' IDENTIFIED BY 'database_password';

After making the above changes, try to remotely connect to the MySQL database server once more. The connection should be successful as shown in the following screenshot.

# mysql -u database_username -p -h 10.24.96.6
Connect to Remote MySQL Database Server
Connect to Remote MySQL Database Server

We hope this solution helped you in solving your Mysql remote connection error. If have any queries reach us via the feedback form below.

If You Appreciate What We Do Here On TecMint, You Should Consider:

TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Support Us

We are thankful for your never ending support.

Source link

- Advertisement -

More articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest article

Packers vs Buccaneers live stream: how to watch NFL week 6 online from anywhere now

This could be tasty. Amazingly, the 36-year-old Aaron Rodgers and 43-year-old Tom Brady have only ever faced each other twice before - in 2014...

Jets vs Dolphins live stream: how to watch NFL week 6 online from anywhere now

The Jets are going to Miami this weekend, where they'll be trying to wrestle their first win of the season from the 2-3 Dolphins....

7 Best Free Case Converter Online|Title Capitalization Tool In 2020

While it’s possible to change case of a couple of sentences manually, doing the same for long paragraphs can be burdensome. This is where...

PopSockets Is Developing New MagSafe-Compatible Grips

With the launch of the newest iPhone 12 series, Apple revived the MagSafe charging system for its mobile devices. Although there is an array...