Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

trying to connect to mysql and getting error :is not allowed to connect to this MySQL serverConnection closed by foreign host

Tags:

mysql

Hi i am running two rhel instances in ec2. now i am trying to do $telnet ec2-184-73-58-163.compute-1.amazonaws.com 3306

Trying 10.193.139.147...
Connected to ec2-184-73-58-163.compute-1.amazonaws.com.
Escape character is '^]'.
bHost 'domU-12-31-39-05-3D-E6.compute-1.internal' is not allowed to connect to this MySQL serverConnection closed by foreign host.

I am a newbie. not getting what to do now? Please help.

like image 402
Maverick Avatar asked Jun 20 '12 03:06

Maverick


People also ask

Is not allowed to connect to this MySQL server MySQL data?

This error occurs due to the default configuration your MySQL database is currently using. This configuration allows connections only from the 'root' user when coming from 'localhost' and not other IP address ranges.

Can't connect to the server MySQL?

normally means that there is no MySQL server running on the system or that you are using an incorrect Unix socket file name or TCP/IP port number when trying to connect to the server. You should also check that the TCP/IP port you are using has not been blocked by a firewall or port blocking service.


3 Answers

You cannot connect to the remote MySQL if you are not white listed in the MySQL user privileges table.


Let's assume your IP address is 199.255.209.168 and you are trying to log into the MySQL daemon running at IP address 123.238.18.47 by the username rakman with some password

$ mysql -h 123.238.18.47 -u rakman -p
Enter password:
ERROR 1130 (HY000): Host '199.255.209.168' is not allowed to connect to this MySQL server

A mysql user [rakman]@[your IP address] needs to be present in the user privileges of MySQL running at 123.238.18.47. So [email protected] (or rakman@% which will allow logging in to this MySQL from ANY remote host but is not recommended) needs to be present in the user privileges of MySQL running at 123.238.18.47.

For the MySQL commands on how to achieve this, you can see the accepted answer at Host 'xxx.xx.xxx.xxx' is not allowed to connect to this MySQL server. If you try to login after that.

$ mysql -h 123.238.18.47 -u rakman -p
Enter password:
Welcome to the MySQL monitor.
like image 100
Rakib Avatar answered Oct 13 '22 20:10

Rakib


You have to give access permission on mysql .

To create a new user:

CREATE USER 'myuser'@'youripaddres' IDENTIFIED BY 'password';

for all ips use below

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

for particular ip use below

GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'youripaddres' WITH GRANT OPTION;

p.s. flush privileges; is needed to take changes into effect.

like image 42
Bipin Avatar answered Oct 13 '22 21:10

Bipin


I am also not that good in this area but i think this link can help you a little. This was my reference when i was having trouble with MySQL.

just try. I hope it works. SourceForge.net

like image 26
James Avatar answered Oct 13 '22 20:10

James