How to Setup MySql Server for Rails 4 Application on Windows
How to Setup MySql Server for Rails 4 Application on Windows

How to Setup MySql Server for Rails 4 Application on Windows

getting rails 4 up and running with MySQL is a little head ache when compared to the Unix rails environments. In this tutorial I will explain how to set up MySQL server for rails 4 application on windows. The latest MySQL connector creates errors while connecting with rails application.  So i recommend you to use 6.0.2 MySQL connector for your rails application.

I assume that you have ruby 2.0 , rails 4 and MySQL server  installed on your windows machine.

ruby on rails 4 -mysql windows

Setting up the environment variable for MySQL

1. Set up the environment variable for MySQL server, so that you can use the server from the command line. If you do not set up the environment variable you won’t be able to access the MySQL server from the command line.

2. Find out the installation directory for MySQL in the C. The path for the installation directory would look like following path.

C:Program FilesMySQLMySQL Server 5.6bin

3. Now open my computer –> right-click and select properties –>click advanced settings from the left top options –> click environment variables –> scroll down and sect path –> click edit –> append the path to the existing line.
setting environment variable for mysql

4. Now you will be able to connect to MySQL server from the command line. You can test it by typing the following command in the command line.

 mysql -u root -pyour_password

5. next step is to configure the MySQL connector for the rails application to work properly.

6. Download 6.0.2 mysql connector form dev.mysql.com and extract it to the C: folder

7.  Now browse to the lib folder from the connector folder and copy the libmysql.dll  to the bin folder of your ruby installation. It looks somewhat like this C:RailsInstallerRuby2.0.0bin

8.  Now install the MySQL ruby gem using the following command.

gem install mysql --platform=ruby -- --with-mysql-dir="C:/mysql-connector-6.0.2-win32"

9. make sure that you use the correct folder name for the connector.

10. After successful execution of the above command, you can start using your rails application with MySQL.

11. If you have an existing rails application , you can execute the following command to make changes to your database.

 bundle exec rake db:migrate

Leave a comment for queries.

0 Shares
Copy link
Powered by Social Snap
0 Shares
Copy link
Powered by Social Snap
0 Shares
Share via
Copy link
Powered by Social Snap