Learning Ruby on Rails with MySQL on a Ubuntu machine is quick and easy with sqlite3 – the default for a Rails project. On a production project though you will probably need a database with a little bit more muscle. Let’s install MySQL and the needed connectors to get Rails to talk to it.
Make sure MySQL and all the necessary development packages are installed:
sudo apt-get install mysql-client-5.1 mysql-server-5.1 \ libmysqlclient16 libmysqlclient16-dev
Then get the needed RubyGems packages:
sudo gem install mysql
Then if you start a new project with MySQL:
rails new mysqltest -d mysqlAnd try to run the console:
cd mysqltest/ rails console
You will probably get an error like this:
Could not find gem 'mysql2 (>= 0, runtime)' in any of the gem sources listed in your Gemfile. Try running `bundle install`.
Easy enough… do as it says:
bundle installYou should see “Installing mysql2 (