views:

4419

answers:

7

I am running a Rails app so now I am trying to remote connect to mysql and I am getting this error Could not connect: Lost connection to MySQL server at 'reading initial communication packet', system error: 0

A: 

"Lost connection to MySQL server at ‘reading initial communication packet’, system error: 0" is the client side error message. Do you have access to the server logs, both the mysqld logs and syslog?

VolkerK
+1  A: 

check from that host

shell> telnet IP 3306

If MySQL is up and reachable you'll see mysql version in telnet output. Otherwise check firewall, etc until telnet succeeds.

Then I advice you first connect with native mysql client to exclude Rails from problem aria.

noonex
+1  A: 

Thank you guys for your effort, I have found the solution, I was suppose to set Remote Connection to MySQLhere is the link for someone who got the same error http://benrobb.com/2007/01/15/howto-remote-root-access-to-mysql/

Steven
+2  A: 

You might want to check your /etc/hosts.deny where:

ALL: ALL: DENY

or

mysqld: ALL: DENY

is your enemy.

This solved it. Was the last barrier after fixing my.cnf and forwarding 3306.
f1sh
A: 

You need to edit your mysql Configuration file, by default the bind-adress is set to 127.0.0.1.

Open: /etc/mysql/my.cnf

Change the bind-adress to the ip you are going to use to connect yoursef to the database server.

mnml
Hey I changed that but still the problem didn't solve.
Madhup
+1  A: 

Enable remote access

The MySQL server does not listen on the TCP port 3306 by default. To allow (remote) TCP connections, comment the following line in /etc/mysql/my.cnf:

skip-networking

Remember to edit /etc/hosts.allow by adding the following lines:

mysqld: ALL : ALLOW

mysqld-max: ALL : ALLOW

Federico Jaramillo
A: 

mysqld-max: ALL : ALLOW solved the problem for me

Ben