12

I'm trying to connect remotely to MySQL server as following:

below code works fine

mysql -u root -h localhost -p  

below code returns me an error

 mysql -u root -h 'server ip_address here' -p

ERROR 1130 (00000): Host xxx is not allowed to connect to this MySQL server

Please help

Madhura Jayaratne
  • 2,204
  • 1
  • 15
  • 20
  • That is because MySQL is not allowing you to connect from that address. Default is that only localhost van connect – MKroeders Oct 10 '13 at 06:31
  • You should configure mysql to allow remote connections. And also you should grant permission to the database you are connecting to from remote IP – Deepak Oct 10 '13 at 06:32

2 Answers2

18

One has to create a new MySQL User and assign privileges as below in Query prompt via phpMyAdmin or command prompt:

CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';

GRANT ALL PRIVILEGES ON *.* TO 'username'@'localhost' WITH GRANT OPTION;

CREATE USER 'username'@'%' IDENTIFIED BY 'password';

GRANT ALL PRIVILEGES ON *.* TO 'username'@'%' WITH GRANT OPTION;

Once done with all four queries, it should connect with username / password

RESTART WAMP / LAMP Server and it should work !

Aditya P Bhatt
  • 21,431
  • 18
  • 85
  • 104
8

Simply run de two commands below

GRANT ALL PRIVILEGES ON *.* TO '**YourUserName**'@'**your IP**' IDENTIFIED BY '**yourPassoword**';

flush PRIVILEGES;

and It will be fine, go on :)

George
  • 6,886
  • 3
  • 44
  • 56
Chair
  • 362
  • 2
  • 8