Working through the development of my Ruby on Rails application, what should have been a straightforward task turned into a challenge when I encountered test database locking issues on SQLite. It was evident that a transition to MySQL was necessary, sooner than expected. I initially followed a tutorial that provided valuable information but encountered unexpected hurdles during the process.
Here are the steps that finally worked for me after a series of trial and errors:
- Install MySQL: Begin by installing MySQL, a process well-documented in various tutorials available online. Once installed, move on to the next steps.
- Download MySQL Web Community 8.0.3 Installer: Download the MySQL Web Community 8.0.3 installer and include the MySQL Connector/C++ 8.0 within this tool. For a 64-bit machine, install version 8.0.33 – X86.

- Command Line Execution: Open the command prompt (cmd) and navigate to your Ruby folder. For example, if it’s in “C:\Program Files\MySQL\Connector C++ 8.0”, run the following command
gem install mysql2 --platform=ruby -- --with-mysql-lib="C:\Program Files\MySQL\Connector C++ 8.0\lib64"
Ensure you adjust the path accordingly. This step is crucial for successful installation.
- Verification: After executing the command, you should see the message “1 gem installed.” This indicates that the MySQL2 gem has been successfully installed.
- Testing the Application: Test your Ruby on Rails application using MySQL.
rails new TestMySQL -d mysql
Errors I encountered:
After testing the application, following the tutorial, using the 6.1.11 version, I was receiving the following error when trying to use MySQL.
Incorrect MySQL client library version! This gem was compiled for 6.1.11 but the client library is 10.5.5
By following these steps, I overcame the challenges in transitioning to MySQL for my Ruby on Rails application on Windows. Feel free to refer to the provided tutorial for additional insights.