One of my clients contacted me for a linked server issue between SQL Server and MySQL Server. Since I mostly work with SQL Server, it was a fun installing and connecting MySQL Server. While I was trying to simulate the issue and I wanted to create a linked server. In this blog, we would learn how to fix MySQL connection error [MySQL][ODBC 5.3(w) Driver]Host ‘IP’ is not allowed to connect to this MySQL server.
I installed MySQL Server on a server and provided the root user’s password. When I was trying to connect to MySQL Server using ODBC.
As soon as I clicked on the test, I see below error.
The IP mentioned in error message is IP of the client which is trying to connect. The text message is as follows:
[MySQL][ODBC 5.3(w) Driver]Host ‘IP’ is not allowed to connect to this MySQL server:
I have never seen this error while working with SQL Server, so I had no idea about this error. When I was researching I learned below.
By default, MySQL does not allow remote clients to connect to the MySQL database.
The fastest way to verify that is as below. If we check mysql.user table, there is an entry for user ‘root’ with host ‘localhost’.
So, we need to provide permission to connect to MySQL Server to a client.
First, make sure it is not a firewall issue.
As we discussed earlier, it’s an issue with permissions. We can then give permission using the command.
Use mysql; GRANT ALL ON *.* to root@'x.x.x.x' IDENTIFIED BY 'your-root-password';
You can also use MySQL Workbench to do that. Below screenshot tells the steps to be followed. Same as the command, we need to give username, password, and IP in the graphical screen.
Hope this blog would help. After the above changes, when you try to connect to the mysql database from this remote client (we have given the IP/hostname), you should not get the “Host is not allowed to connect to this MySQL server” error message anymore. We can also use % to allow all hosts but I don’t prefer that option.
I am not a MySQL expert so feel free to comment and let me know if there are better ways.
Reference: Pinal Dave (https://blog.sqlauthority.com)