Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Connecting to remote DB 1

Status
Not open for further replies.

Jonah86

Programmer
Dec 11, 2003
152
US
Hello. I'm just a beginner here, so I appologize for any stupid questions.

I'm trying to get Ruby on Rails to connect to a remote MySQL databse I've set up. I'm able to use a MySQL database setup on my local machine just fine, but when I copy it to our server and change the databse.yml file to point to the server, I get an error saying that it lost connection to the database durring the query. The host IP address, user name and password are all set in the .yml file. I can't figure out why it'd be losing the connection. Is there something I have to have running on the DB server?

As I said, I'm very new to this. Just started learning it last Friday, so be gentle.
 
If the database server is running on a different machine, the MySQL user you are using must explicitly be allowed from the host. Try this:

Code:
sh$ mysql -u root -p mysql
mysql> select host, user from user;

You should see a host/user combination that matches your setup. If not, use the GRANT command to add the user from the host.

-
 
Thank you very much for your quick reply!

My user name has access from %, which I thought was wildcard. I did explicitly set my username and hostname of the computer I'm working on, and it still wouldn't connect.

Anything else I might be doing wrong?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top