Ruby on Rails uses SQLite3 as its default database. While Sqlite works great with Rails, some times it may not be sufficient for your Rails applicatio

How To Use MySQL With Ruby On Rails Application

submited by
Style Pass
2021-05-19 07:42:05

Ruby on Rails uses SQLite3 as its default database. While Sqlite works great with Rails, some times it may not be sufficient for your Rails application. If you want scalability, concurrency, centralization, and control, you may want to try more robust databases like MySQL or PostgreSQL. In this guide, we will see how to use MySQL with Ruby on Rails application in Ubuntu Linux.

The libmysqlclient-dev package provides the necessary files to compile the mysql2 gem. Ruby on Rails uses mysql2 gem to connect to MySQL when you setup a Rails application.

Choose the level of password validation. The available password validations are low, medium and strong. Here, I choose low level password validation by entering zero (0).

Next, enter MySQL Root password twice. The password should be strong and should have minimum 8 characters. Press Y to continue:

Next, you will be asked a series of questions. Type y and hit ENTER for each question. This will remove anonymous user, disallow root user login remotely and remove test database.

Leave a Comment