This should be dead simple, but I cannot get it to work for the life of me.
I'm just trying to connect remotely to my MySQL server.
connecting as
mysql -u root -h localhost -p
works fine, but trying
mysql -u root -h 'any ip address here' -p
fails with the error
ERROR 1130 (00000): Host ''xxx.xx.xxx.xxx'' is not allowed to connect to this MySQL server
In the mysql.user
table, there is exactly the same entry for user 'root' with host 'localhost' as another with host '%'.
I'm at my wits' end, and have no idea how to proceed. Any ideas are welcome.
One has to create a
new MySQL User
and assign privileges as below inQuery prompt
via phpMyAdmin or command prompt:Once done with all four queries, it should connect with
username / password
Most of the answers here show you creating users with two host values: one for
localhost
, and one for%
.Please note that except for a built-in localhost user like root, you don't need to do this. If you simply want to make a new user that can log in from anywhere, you can use
and it will work just fine. (As others have mentioned, it's a terrible idea to grant administrative privileges to a user from any domain.)
On the off chance that someone facing this issue is experiencing it from within SQLyog, this happened:
I had connected to the remote database (from within SQLyog) and worked for some hours. Afterwards I left the system for some minutes, then came back to continue my work - ERROR 1130 ! Nothing I tried worked; Restarting SQLyog didn't fix it. Then I restarted the system - it still didn't work.
So I tried connecting from the terminal - it worked. Then retried it on SQLyog ... and it worked. I can't explain it other than 'random computer quirkiness', but I think it might help someone.
Just find a better way to do that from your hosting control panel (I'm using DirectAdmin here)
simply go to the target server DB in your control panel, in my case: MySQL management -> select your DB -> you will find: "Access Hosts", simply add your remote host here and its working now!
I guess there is a similar option on other C.panels like plesk, etc..
I'm hope it was helpful to you too.
My error message was similar and said 'Host XXX is not allowed to connect to this MySQL server' even though I was using root. Here's how to make sure that root has the correct permissions.
My setup:
Solution
Check for:
Now access the MySQL Database on your actual server (say your remote address is 123.123.123.123 at port 3306 as user 'root' and I want to change permissions on database 'dataentry'. Remember to change the IP Address, Port, and database name to your settings)
sudo service mysqld restart
If you happen to be running on Windows; A simple solution is to run the MySQL server instance configuration wizard. It is in your MYSQL group in the start menu. On the second from last screen click the box that says "allow root access from remote machines".