Skip to content

Instantly share code, notes, and snippets.

@egalink
Created July 6, 2017 18:19
Show Gist options
  • Save egalink/c4edd08b664fd1a04785eec7dee43fed to your computer and use it in GitHub Desktop.
Save egalink/c4edd08b664fd1a04785eec7dee43fed to your computer and use it in GitHub Desktop.
ERROR 1130 (HY000): Host is not allowed to connect to this MySQL server.

1130-HY000

ERROR 1130 (HY000): Host is not allowed to connect to this MySQL server.

Why you cannot connect to mysql remotely?

Your root account, and this statement applies to any account, may only have been added with localhost access (which is recommended).

You can check this with:

SELECT host FROM mysql.user WHERE User = 'root';

If you only see results with localhost and 127.0.0.1, you cannot connect from an external source. If you see other IP addresses, but not the one you're connecting from - that's also an indication. If you see %, well then, there's another problem altogether as that is "any remote source"

You should be able to add this remote access with:

GRANT ALL PRIVILEGES ON . TO 'user'@'%' IDENTIFIED BY 'password'; FLUSH PRIVILEGES;

A typical firewall issues if you are using Windows OS particularly windows 7 or 8

This is a typical firewall issues if you are using Windows OS particularly windows 7 or 8. Disabling your firewall from the Antivirus on your server (where your MySQL is installed) might not help.

Follow this steps:

  1. Go to the control panel of your Server (wamp server PC)
  2. Go System and Security
  3. Choose Windows Firewall
  4. Choose Advance Settings
  5. Choose Inbound Rule
  6. Choose New Rule - New Inbound Rule Wizard will pop up
  7. Choose Port and click next
  8. Choose TCP and click next
  9. Enter 80, 3306 (These are default ports respectively for Apache and Mysql servers on wamp) if you have changed them on your wamp server PC then indicate the appropriate ports
  10. Choose Allow the Connection
  11. Check or uncheck whether you will allow this ports on Private, Public or Domain Network
  12. Give the rule a name and click finish

Enjoy!

@codertjay
Copy link

On ubuntu or linux os you can fix it by .

sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf
modify bind address to

bind-address = 0.0.0.0
Afer that connect to your my sql console

sudo mysql -u root -p
create user  'user'@'%' identified by 'password';
grant all on *.* to  'user'@'%';
exit;

Then restart the mysql server

sudo systemctl restart mysql
Note: i actually had issues updating a user so i created a new user for remote connection which would have all the permission

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment