Installing MySQL For Ruby On Rails

If you are working with Rails, you will need to install a database. While there are quite a few possible choices available to you, one of the most widely used is MySQL. You can download and install MySQL for free. However, if you’ve never used MySQL before, you may find some of the setup options confusing. In this tutorial, we’ll try to guide you through the process to avoid potential problems…

Download MySQ
The MySQL main site is at http://www.mysql.com/ and from here you can navigate to the download page for the current version.

I shall assume that you will be using the free edition of MySQL. This is available for download on the page. The current version, at the time of writing, is MySQL 5 Community Server. The name and version number will, of course, change over time. Download whichever is the current (not upcoming, alpha or beta) release. Choose the specific version recommended for your operating system (there may be different versions for Win32 and Win64, for example).

You will need to scroll some way down this page to locate the Windows installers. You can either download the complete MySQL package or the smaller Windows Essentials package. The complete package contains extra tools for database developers but these are not required for simple Rails development. For most people, therefore, the smaller Windows Essentials download file is the one to get.

You should click the ‘Pick A Mirror’ link alongside this option. You will then be shown a questionnaire which you can fill out if you wish. If you don’t wish to do so, just scroll down the page and pick a regional download site. Click a link and save the file, which will be named something like (the numbers may differ): mysql-essential-5.0.41-win32.msi, to any convenient directory on your disk.

Install MySQL
Once the download has completed run the program by selecting Open or Run in the download dialog if this is still visible, or by double-clicking the installation file via Windows Explorer.
The first page of the Setup Wizard will now appear. Click the Next button.

1-Installing MySQL For Ruby On Rails

You can either leave the Typical setup option selected if you are happy to install the software into the default MySQL directory beneath C:\Program Files\. If you want to install to some other directory, however, select Custom. Then click Next. Click Change to change the directory.

2-Installing MySQL For Ruby On Rails
When you are ready to move on, click Next. You will see the screen stating ‘Ready To Install the Program’, verify that the destination folder is correct, then click the Install button.

3-Installing MySQL For Ruby On Rails
Depending on the version of MySQL you may now either be shown some promotional screens or you may be prompted to create a new MySQL account which will let you receive news of changes and updates. These are not an essential part of the software installation and you may click the Next or Skip buttons to move on through the installation.

The Wizard Completed dialog now appears. Click the Finish button.

4-Installing MySQL For Ruby On Rails

 

Configure MySQL
In fact, this isn’t the end of the installation after all. With some installers, a new screen pops up now welcoming you to the MySQL Server Instance Configuration Wizard. If this does not occur, you will need to load this yourself. Click the Start menu, then Program->MySQL->MySQL Server 5.0 (or whichever version number you are using) then MySQL Server Instance Config Wizard.

Click Next. Assuming that this is the first time you’ve installed MySQL on this machine, you can select Standard Configuration (if you are upgrading from an older version of

5-Installing MySQL For Ruby On Rails

In the next dialog, leave the default options selected (i.e. Install As Windows Service; Service Name = ‘MySQL’ and Launch the MySQL Server automatically). Then click Next.

6-Installing MySQL For Ruby On Rails
In the next screen, leave ‘Modify Security Settings’ checked and enter the same password (of your choice) into the first two text fields. You will need this password later so remember it or write it down in a secure location. If you may need to access MySQL from another computer you can check ‘Enable root access from remote machines’. Then click Next.

7-Installing MySQL For Ruby On Rails
Note: The default MySQL user name is ‘root’. The password is the one you just entered. You will need both these items of information later when creating Rails applications.

The next screen just gives you some information about the tasks that are about to be performed. Click the Execute button.

8-Installing MySQL For Ruby On Rails
If you have previously installed or configured MySQL, you may see an error message which tells you to Skip the installation. You may click Retry to see if you can bypass this problem. If not, press Skip and then restart the MySQL configuration process, selecting Reconfigure Instance and Standard Instance when prompted.

9-Installing MySQL For Ruby On Rails
If you have previously installed or configured MySQL, you may see an error message which tells you to Skip the installation. You may click Retry to see if you can bypass this problem. If not, press Skip and then restart the MySQL configuration process, selecting Reconfigure Instance and Standard Instance when prompted.

10-Installing MySQL For Ruby On Rails

 

When everything is installed this screen appears. Click Finish.

And that’s it!

11-Installing MySQL For Ruby On Rails

Just to test that everything’s working, you can open the MySQL command line client. You can do this from the MySQL group on the Windows start menu. A ‘DOS box’ will appear and you will be prompted to enter your password. Once you’ve entered this, you will be welcomed to the MySQL monitor with a mysql> prompt. Enter \h for some help. Enter quit to exit.