Saturday, May 7, 2016

Setting up the MySQL database

The Blacklight app uses a sqlite3 database by default, but the Blacklight project recommends using a MySQL or PostgreSQL database for a production deployment. The CentOS VPS server through Bluehost already has MySQL installed, so we will use that for our production database.

Side note: I did try to install and use the PostgreSQL database, but ran into several problems along the way. This prompted me to go with MySQL instead since it was already installed and mostly configured.

Setting up the MySQL database for the app

1. Go to your Bluehost cPanel and find the "Database tools" section. In this section, click on the "MySQL Databases" icon to create the database and database user.

 

2. On the next screen, find the "Create a New Database" form and type in the name of your database. You can name it whatever you like - I'll call it "test-app_production" in this example. Then click the Create Database button. You'll most likely be taken to a confirmation screen. From there, go back to the MySQL Databases page using the link provided.


3. Next, go to the "MySQL Users" section to create the database user. Fill in the form with a username and password. Then click the "Create a User" button. You'll most likely be taken to a confirmation screen again. From there, go back to the MySQL Databases page using the link provided.


4. Go to the "Add a User to a Database" section and select the correct username and database from the dropdown menu. Then click the "Add" button.

 

5. You will be taken to a page where you can select the privileges for this user. Select "All Privileges" and then click the "Make Changes" button. Once you see the confirmation that the changes were saved, go back to the MySQL Databases page with the link provided.



6. Head back to your cPanel next. We need to make a change to the collation of the database before we're done with MySQL setup. Find the database tools section again and click on the phpMyAdmin icon. This will take us to the phpMyAdmin interface, where we can make changes to the structure and contents of the database.


7. In the phpMyAdmin interface, click on the Databases tab to see a list of your databases.


8. Click on the database you just created (in our case, it is "test-app_production").


9. Click on the "Operations" tab.


10. Select "utf8_bin" in the Collation select menu and click save. The default "latin1_swedish_ci" won't work with the Blacklight installation. The "latin1_swedish_ci" collation does not support all of the characters Blakclight will be inserting into the database tables, so if we don't change this we will get an error during the database migration step later on.


11. After the new collation is saved, close out of the phpMyAdmin interface. Your MySQL database should now be configured for use with the Blacklight app.


Previous post: Installing Rails

Next post: Installing Solr

4 comments: