# Using multiple mysql databases

**URL:** <https://www.ruby-forum.com/t/using-multiple-mysql-databases/104825>\
**Category:** Rails\
**Created:** [May 22, 2007, 11:45pm UTC](https://www.ruby-forum.com/t/using-multiple-mysql-databases/104825 "2007-05-22T23:45:36Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kevin\_ySkim](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/5daacb/32.png) [@kevin\_ySkim](https://www.ruby-forum.com/u/kevin_ySkim)\
**Post date:** [May 22, 2007, 11:45pm UTC](https://www.ruby-forum.com/t/using-multiple-mysql-databases/104825/1 "2007-05-22T23:45:36Z")

</div>

Hi,

I’ve got an app that talks to two databases on a given MySQL server.  
When I run in development mode, pointing to the MySQL server running  
on localhost (127.0.0.1),  
I am able to access both databases without any problem. The relevant  
yaml looks like this:  
(names have been changed to protect the innocent)

development:  
adapter: mysql  
database: dev  
username: username  
password: password  
hostname: 127.0.0.1

dev2:  
adapter: mysql  
database: dev2  
username: username  
password: password  
hostname: 127.0.0.1

When I change the environment to “production”, I am unable to access  
the database that is _not_ named “production”. I get an error that  
reads “Mysql::Error: Unknown database ‘prod2’”. The production part  
of the yaml looks like:

production:  
adapter: mysql  
database: prod  
username: username  
password: password  
hostname: [db.prod.mycompany.com](http://db.prod.mycompany.com)

prod2:  
adapter: mysql  
database: prod2  
username: username  
password: password  
hostname: [db.prod.mycompany.com](http://db.prod.mycompany.com)

When I change the “development” and “dev2” to point to the production  
server and tables, I get the same error.

This leads me to believe that the dev and prod mysql servers are  
configured differently, but I wanted to double check and see if anyone  
has seen this problem before (and that it might be rails).

Anyone?

Thanks,  
-kevin
