# Connecting to a Remote MySQL Server

**URL:** <https://www.ruby-forum.com/t/connecting-to-a-remote-mysql-server/96325>\
**Category:** Rails\
**Created:** [June 28, 2006, 3:21am UTC](https://www.ruby-forum.com/t/connecting-to-a-remote-mysql-server/96325 "2006-06-28T03:21:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![lisa-u](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/f19dbf/32.png) [@lisa-u](https://www.ruby-forum.com/u/lisa-u)\
**Post date:** [June 28, 2006, 3:21am UTC](https://www.ruby-forum.com/t/connecting-to-a-remote-mysql-server/96325/1 "2006-06-28T03:21:58Z")

</div>

Hi All.

I have one newbie question-

How do I connect to a remote MySQL server using Ruby on Rails? Is it  
something simple like changing a few lines in database.yml??

Thanks in advance.

Lisa

---

<div class="post-metadata">

**Author:** ![lisa-u](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/f19dbf/32.png) [@lisa-u](https://www.ruby-forum.com/u/lisa-u)\
**Post date:** [June 28, 2006, 3:44am UTC](https://www.ruby-forum.com/t/connecting-to-a-remote-mysql-server/96325/2 "2006-06-28T03:44:12Z")

</div>

add

host: \<remote\_mysql\_hostname\>

to the pertinent sections (developement, test, production) in  
database.yml. of course, make sure the user on the remote mysql  
database is allowed to connect remotely.

---

<div class="post-metadata">

**Author:** ![lisa-u](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/f19dbf/32.png) [@lisa-u](https://www.ruby-forum.com/u/lisa-u)\
**Post date:** [June 28, 2006, 3:47am UTC](https://www.ruby-forum.com/t/connecting-to-a-remote-mysql-server/96325/3 "2006-06-28T03:47:20Z")

</div>

On Wed, Jun 28, 2006 at 03:21:58AM +0200, lisa-u wrote:

> How do I connect to a remote MySQL server using Ruby on Rails? Is it  
> something simple like changing a few lines in database.yml??

Most examples set the database hostname to “localhost” - just change  
your to the name of the remote server. Provide the correct username and  
password, and make sure that you have access across the firewalls, if  
any.

development:  
adapter: mysql  
database: dev  
username: dbuser  
password: dbuserpass  
host: [remote.database.com](http://remote.database.com)
