# How to configure rails to use mysql by default (not sqlite3)

**URL:** <https://www.ruby-forum.com/t/how-to-configure-rails-to-use-mysql-by-default-not-sqlite3/192624>\
**Category:** Rails\
**Created:** [August 3, 2010, 9:08am UTC](https://www.ruby-forum.com/t/how-to-configure-rails-to-use-mysql-by-default-not-sqlite3/192624 "2010-08-03T09:08:46Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![reivilo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/0ea827/32.png) [@reivilo](https://www.ruby-forum.com/u/reivilo)\
**Post date:** [August 3, 2010, 9:08am UTC](https://www.ruby-forum.com/t/how-to-configure-rails-to-use-mysql-by-default-not-sqlite3/192624/1 "2010-08-03T09:08:46Z")

</div>

Hello,

I am running Mac OS X 10.6.4 and have installed the following:

ruby-1.9.1-p429 (64 bits, I believe!)  
RubyGems 1.3.7  
Rails 2.3.8  
MySQL 5.1.49 (64 bits)

I am now getting an error because sqlite3 is not installed and I’ve read  
that there are issues installing ruby-sqlite3! SO I’m not sure if I  
should (or how to) install sqlite3.

A developer suggested I use sqlite3 for testing and mysql for  
production, but wouldn’t that mean having to convert my sqlite database  
to mysql for production? I might just as well always use mysql, no?

Which leads me to the following question: how do I configure rails to  
always default to using mysql database instead of sqlite3?

Thank you for your help.

Best regards,

Olivier

---

<div class="post-metadata">

**Author:** ![reivilo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/0ea827/32.png) [@reivilo](https://www.ruby-forum.com/u/reivilo)\
**Post date:** [August 3, 2010, 12:07pm UTC](https://www.ruby-forum.com/t/how-to-configure-rails-to-use-mysql-by-default-not-sqlite3/192624/2 "2010-08-03T12:07:30Z")

</div>

just add -d mysql option when you create a new rails project

---

<div class="post-metadata">

**Author:** ![reivilo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/0ea827/32.png) [@reivilo](https://www.ruby-forum.com/u/reivilo)\
**Post date:** [August 4, 2010, 4:41am UTC](https://www.ruby-forum.com/t/how-to-configure-rails-to-use-mysql-by-default-not-sqlite3/192624/3 "2010-08-04T04:41:25Z")

</div>

Marnen Laibow-Koser wrote:

> Olivier Db wrote:
> 
> > Hello,
> > 
> > I am running Mac OS X 10.6.4 and have installed the following:
> > 
> > ruby-1.9.1-p429 (64 bits, I believe!)  
> > RubyGems 1.3.7  
> > Rails 2.3.8  
> > MySQL 5.1.49 (64 bits)
> > 
> > I am now getting an error because sqlite3 is not installed
> 
> SQLite comes with Mac OS. The OS uses it internally. No installation  
> should be necessary, though you will probably have to install the  
> sqlite3 gem.

I’m not completely sure, but I don’t think SQLite is installed on Mac OS  
X unless Xcode developer tools are installed. However, many gems need  
the gcc compiler, which is also not installed until Xcode is installed.

Conclusion… Install Xcode developer tools. The installed comes with  
Mac OS X.

---

<div class="post-metadata">

**Author:** ![reivilo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/0ea827/32.png) [@reivilo](https://www.ruby-forum.com/u/reivilo)\
**Post date:** [August 3, 2010, 6:03pm UTC](https://www.ruby-forum.com/t/how-to-configure-rails-to-use-mysql-by-default-not-sqlite3/192624/4 "2010-08-03T18:03:43Z")

</div>

Olivier Db wrote:

> Hello,
> 
> I am running Mac OS X 10.6.4 and have installed the following:
> 
> ruby-1.9.1-p429 (64 bits, I believe!)  
> RubyGems 1.3.7  
> Rails 2.3.8  
> MySQL 5.1.49 (64 bits)
> 
> I am now getting an error because sqlite3 is not installed

SQLite comes with Mac OS. The OS uses it internally. No installation  
should be necessary, though you will probably have to install the  
sqlite3 gem.

> and I’ve read  
> that there are issues installing ruby-sqlite3!

Not to my knowledge.

> SO I’m not sure if I  
> should (or how to) install sqlite3.
> 
> A developer suggested I use sqlite3 for testing and mysql for  
> production, but wouldn’t that mean having to convert my sqlite database  
> to mysql for production?

No. You have separate databases. You’ve also got migrations. No  
conversion is required.

> I might just as well always use mysql, no?

It depends. On the one hand, it’s extremely convenient and fast to use  
SQLite for testing and development. On the other hand, you may find  
that you would rather have the same DB in development as production.  
I’ve done it both ways. Both are fine.

(And I would say you might as well _never_ use MySQL. PostgreSQL is a  
much, much better DB.)

> Which leads me to the following question: how do I configure rails to  
> always default to using mysql database instead of sqlite3?

-d mysql

> Thank you for your help.
> 
> Best regards,
> 
> Olivier

## Best,

Marnen Laibow-Koser  
[http://www.marnen.org](http://www.marnen.org)  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![reivilo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/0ea827/32.png) [@reivilo](https://www.ruby-forum.com/u/reivilo)\
**Post date:** [August 5, 2010, 10:41am UTC](https://www.ruby-forum.com/t/how-to-configure-rails-to-use-mysql-by-default-not-sqlite3/192624/5 "2010-08-05T10:41:13Z")

</div>

Kenneth Â Â Â wrote:

> just add -d mysql option when you create a new rails project

when i try to make rails -d mysql example or rails example -d mysql what  
i do get is to rails apps 1 called mysql and another called example.

---

<div class="post-metadata">

**Author:** ![reivilo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/0ea827/32.png) [@reivilo](https://www.ruby-forum.com/u/reivilo)\
**Post date:** [August 4, 2010, 6:11pm UTC](https://www.ruby-forum.com/t/how-to-configure-rails-to-use-mysql-by-default-not-sqlite3/192624/6 "2010-08-04T18:11:57Z")

</div>

Robert W. wrote:  
[…]

> I’m not completely sure, but I don’t think SQLite is installed on Mac OS  
> X unless Xcode developer tools are installed.

I don’t have a Mac without developer tools handy to check, but I am 99%  
certain that you are wrong. SQLite is used by the operating system’s  
CoreData component, so it stands to reason that some form of SQLite is  
bundled into the OS regardless of developer tools.

## Best,

Marnen Laibow-Koser  
[http://www.marnen.org](http://www.marnen.org)  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![reivilo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/0ea827/32.png) [@reivilo](https://www.ruby-forum.com/u/reivilo)\
**Post date:** [August 5, 2010, 11:00am UTC](https://www.ruby-forum.com/t/how-to-configure-rails-to-use-mysql-by-default-not-sqlite3/192624/7 "2010-08-05T11:00:09Z")

</div>

Luis G. wrote:

> Kenneth Â Â Â wrote:
> 
> > just add -d mysql option when you create a new rails project
> 
> when i try to make rails -d mysql example or rails example -d mysql what  
> i do get is to rails apps 1 called mysql and another called example.

ok i know now … i got to use the -D ( capital letter ) not the -d . -d  
is for documentations not for databases definition.

---

<div class="post-metadata">

**Author:** ![reivilo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/0ea827/32.png) [@reivilo](https://www.ruby-forum.com/u/reivilo)\
**Post date:** [August 5, 2010, 5:10pm UTC](https://www.ruby-forum.com/t/how-to-configure-rails-to-use-mysql-by-default-not-sqlite3/192624/8 "2010-08-05T17:10:04Z")

</div>

Marnen Laibow-Koser wrote:

> I don’t have a Mac without developer tools handy to check, but I am 99%  
> certain that you are wrong. SQLite is used by the operating system’s  
> CoreData component, so it stands to reason that some form of SQLite is  
> bundled into the OS regardless of developer tools.

You’re probably right about SQLite, but still the dev tools will likely  
be needed for compiling sqlite3-ruby native extensions. So whether  
SQLite is there or not without the dev tools is moot anyway. Still have  
to install the dev tools to use Rails effectively.

---

<div class="post-metadata">

**Author:** ![reivilo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/0ea827/32.png) [@reivilo](https://www.ruby-forum.com/u/reivilo)\
**Post date:** [August 5, 2010, 5:21pm UTC](https://www.ruby-forum.com/t/how-to-configure-rails-to-use-mysql-by-default-not-sqlite3/192624/9 "2010-08-05T17:21:58Z")

</div>

Robert W. wrote:

> Marnen Laibow-Koser wrote:
> 
> > I don’t have a Mac without developer tools handy to check, but I am 99%  
> > certain that you are wrong. SQLite is used by the operating system’s  
> > CoreData component, so it stands to reason that some form of SQLite is  
> > bundled into the OS regardless of developer tools.
> 
> You’re probably right about SQLite, but still the dev tools will likely  
> be needed for compiling sqlite3-ruby native extensions. So whether  
> SQLite is there or not without the dev tools is moot anyway. Still have  
> to install the dev tools to use Rails effectively.

Exactly. (Which is why I don’t have a Mac without dev tools handy… 🙂  
)

## Best,

Marnen Laibow-Koser  
[http://www.marnen.org](http://www.marnen.org)  
removed\_email\_address@domain.invalid
