Hi,
Tried to configure the database.yml file to point to a remote mysql
database but faced an error “Connection refused - connect(2)”.
Here’s a copy of my database.yml configuration.
development:
adapter: mysql
encoding: utf8
host:
port:
database:
username:
password:
socket:
Would appreciate any assistance in this area, as I can’t seem to find
any articles on Ruby connecting to a remote mysql database. I’m sure
that the username and password works. Is there something that I might
missed out?
Thanks! = ]
Hi marTyN,
This post probably belongs on a MySQL mailing list, not a Rails one,
but…
It appears that you need to configure the MySQL permissions on your
remote database server to allow remote connections from your
“originating” host (for the username/password combo you configure in
your yml file). The other thing to check is that the firewall on your
remote server allows incoming connections (on port 3306 - by default).
FYI,
Peter
On Tue, Jun 10, 2008 at 11:21 PM, marTyN [email protected] wrote:
database:
username:
password:
socket:
WAG: remove the ‘socket’ entry
HTH,
Hassan S. ------------------------ [email protected]
Hi,
I have the exact same problem for connecting to remote DB.
-
This is not a mysql issue, as I can remotely connect to the server
user mysql-client
-
I don’t have the host option in my database.yml
I made a typo, one should read:
- I don’t have the socket option in database.yml
Anyway, I could go a step further by installing gem mysql, and now I
get:
Can’t connect to MySQL server on ‘10.0.0.2’ (111)
does this:
give you this:
Trying mysql.database.com…
Connected to mysql.database.com (mysql.database.com).
Escape character is ‘^]’.
;
5.1.22-rc-logg?
??
do you have the mysql client locally? you could try this:
Here is an example of the database.yml:
production:
username: username
adapter: mysql
port: 3306
host: mysql.database.com
password: password
database: my_app_production
mysql gem or not, you should be able to connect… sounds like you
need to run this on your mysql server:
mysql> GRANT ALL PRIVILEGES ON my_app_production.* TO
‘username’@‘remote.rails.server’;
I just confirmed that I can connect to a remote db with both an older
(1.2.3) and a newer (2.0.2) rails app.
Do a show grants from a mysql client to make sure your permissions
are set right.
–
Hassan S. ------------------------ [email protected]