Lost connection to MySQL server at 'reading initial communication packet' for remote mysql server

Viewed 4493

I am trying to access remote mysql database using rake task. Here i am posting my active record connection logic

client = ActiveRecord::Base.establish_connection(
:host => "server_ip",
:port => 22,
:adapter  => "mysql2",
:pool => 5,
:database => "database_name",
:username => "username",
:password => "password"
)

I am accessing it using this

client.connection.execute("SELECT * FROM users")

But every time it results with error as given below

rake aborted!
Lost connection to MySQL server at 'reading initial communication packet', system error: 0

Is there anything i am missing. Please suggest me right direction

1 Answers
Related