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
Pierre

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
Submit an Answer
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:

production:
  adapter: mysql
  encoding: utf8
  database: rails_app
  username: rails_user
  password: pwd
  host: 127.0.0.1
  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.