Jason
Jason

Reputation: 177

How to make a Rails application using MySQL?

To make a Rails application with MySQL, I do the following:

rails new application -database=mysql

That doesn't work though, instead it gives my SQLite. I don't want SQLite, I want MySQL.

How can I solve this?

Upvotes: 0

Views: 2177

Answers (3)

maulik bafalipara
maulik bafalipara

Reputation: 248

First of all you need to install mysql2 in your system

sudo  gem install mysql2 -v=0.2.11

Once you have installed mysql2, then you are ready to create a new app with Mysql as default

rails new sample_app -d mysql

Upvotes: 3

Icicle
Icicle

Reputation: 1174

I think you are looking at the command to create new rails app with mysql configuration in database.yml

rails new app --database mysql

I hope it answers your query.

Upvotes: 5

Shamir K.
Shamir K.

Reputation: 395

If you use bundler, then you should add

gem "mysql2"

to your Gemfile and run

bundle install

and then specify your database settings in config/database.yml

Upvotes: 1

Related Questions