Host localhost is not allowed to connect to this mysql server

Ads were blocked - no problem. But keep in mind that developing HeidiSQL, user support and hosting takes time and money. You may want to send a donation instead.

davidfcoozo posted 4 years ago in General

I'm just a noob in this, I'm just learning and I was deleting some users and now when I try to access with root user it gave me the error Host 'localhost' is not allowed to connect to this MariaDB server

Host localhost is not allowed to connect to this mysql server

ansgar posted 4 years ago

Please login to leave a reply, or register at first.

This page uses cookies to show you non-personalized advertising and server usage statistic diagrams.

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
Host localhost is not allowed to connect to this mysql server
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";
Host localhost is not allowed to connect to this mysql server
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";
Host localhost is not allowed to connect to this mysql server
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
Host localhost is not allowed to connect to this mysql 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.

Host localhost is not allowed to connect to this mysql server

We are thankful for your never ending support.

How do I fix MySQL host is not allowed to connect to this server?

To fix this, add a user that allows your host. To allow any host, use the wildcard symbol %. You can add a user from the command line or with a UI client (such as MySQL Workbench or phpMyAdmin).

How do I allow a host to connect to MySQL server?

How to Allow Remote Connections to MySQL.
Step 1: Edit MySQL Config File..
Step 2: Set up Firewall to Allow Remote MySQL Connection. Option 1: UFW (Uncomplicated Firewall) Option 2: FirewallD. Option 3: Open Port 3306 with iptables..
Step 3: Connect to Remote MySQL Server..

How do I access MySQL server on localhost?

Connecting via a standard connection Enter 127.0. 0.1 for the host. The default username for a new MySQL installation is root, with a blank password. You can leave the port field blank unless your server uses a different port than 3306.

What is host localhost in MySQL?

The MySQL hostname defines the location of your MySQL server and database. If you want to connect to the information in a MySQL database, you'll need to know the hostname. Again, the hostname is usually localhost, which indicates that the database is running on the same server as your application (e.g. WordPress).