Forum: Ruby on Rails Remote mySQL Database

Cb996c6207ec7850e2f1422335cf5db9?d=identicon&s=25 Martyn Yap (martynyap)
on 2008-06-11 11:48
(Received via mailing list)
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: <hostname>
  port: <portnumber>
  database: <databasename>
  username: <username>
  password: <password>
  socket: <socketpath>

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! = ]
Daf51c9cccbb229c8820079c6ba46109?d=identicon&s=25 Peter Vandenberk (Guest)
on 2008-06-11 11:56
(Received via mailing list)
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
Bee69cfed999cd13e3bff73d472a39ee?d=identicon&s=25 Hassan Schroeder (Guest)
on 2008-06-11 16:02
(Received via mailing list)
On Tue, Jun 10, 2008 at 11:21 PM, marTyN <martyn.yap@gmail.com> wrote:

>  database: <databasename>
>  username: <username>
>  password: <password>
>  socket: <socketpath>

WAG: remove the 'socket' entry

HTH,
--
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com
059ed46172a087063ce26250e44c8627?d=identicon&s=25 Fernando Perez (fernando)
on 2008-06-11 21:44
Hi,

I have the exact same problem for connecting to remote DB.

1) This is not a mysql issue, as I can remotely connect to the server
user mysql-client

2) I don't have the host option in my database.yml
059ed46172a087063ce26250e44c8627?d=identicon&s=25 Fernando Perez (fernando)
on 2008-06-11 22:03
I made a typo, one should read:

2) 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)
4c438a80fc30661ad619ea177cf9cbd0?d=identicon&s=25 heimdull (Guest)
on 2008-06-11 22:42
(Received via mailing list)
does this:

# telnet mysql.database.com 3306

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:

# mysql -h mysql.database.com -u username -p

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';
Bee69cfed999cd13e3bff73d472a39ee?d=identicon&s=25 Hassan Schroeder (Guest)
on 2008-06-11 23:23
(Received via mailing list)
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 Schroeder ------------------------ hassan.schroeder@gmail.com
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.