How do I connect my Rails app to use MySQL on my digital Ocean droplet?

March 10, 2015 2.1k views
Ruby on Rails MySQL

Hi, my Ruby on Rails demo app runs well with Sqlite. I now need to use MySQL database created on my droplet. Ho would I do this. I would appreciate your support

1 Answer

Generally, in order to use MySql for a Rails app there are a few steps that need to be followed. First, install MySql itself:

sudo apt-get install mysql-server

You’ll also want to create a separate user and database for your app. This tutorial will walk you through creating users in MySql:


Next, require the mysql gem in your app’s Gemfile and re-run bundle install in order to install it.

Then in your config/database.yml file, you’ll need to set the correct information for your app to be able to connect to the database. It would look something like this:

  adapter: mysql
  encoding: utf8
  database: rails_app
  username: rails_user
  password: pwd
  port: 3306
  pool: 10

Hopefully, this points you in the right direction. Let us know how it goes!

by Etel Sverdlov
MySQL is a powerful database management system used for organizing and retrieving data. This tutorial explains how to to create new MySQL users and how to grant them the appropriate permissions.
Have another answer? Share your knowledge.