Many of our users get error in establishing connection with mysql or some other configuration for mysql, so I decided to make this tutorial for Rails with Mysql Configuration.
Off-course to have good or little knowledge of Mysql or any database manager/software is better, but don’t worry if you doesn’t have any knowledge, we will give you a little knowledge in this tutorial, which will help you in Rails with Mysql Configuration.

Pr-Request for Rails with Mysql Configuration

I prefer Kali-Linux because it is good for developing too, it already have soo many developer tools like python, mysql etc. But if you are using any other O.S than you must install it manually.

  1. Install Mysql client and server from here.
  2. Install Mysql Workbench.
  3. Install libmysqlclient-dev using
    sudo apt-get install libmysqlclient-dev

Some Basic Mysql Commands

Changing Mysql Root Password

Some time you need to change your mysql root password, in kali-linux by default there is no password.

  1. Enter into mysql shell using mysql -u root and then enter your old password.
  2. use database mysql using
    use mysql
  3. To show your old password use
    SELECT PASSWORD FROM user WHERE User='root';
  4. Change Password using update command
    UPDATE user SET Password=PASSWORD('1234') WHERE User='root';
  5. Flush all privileges using
    Flush Privileges;

Ruby recommends to create three databases, one for each development, testing and production environment.
According to convention their names should be:

  1. Buffercode_development
  2. Buffercode_production
  3. Buffercode_test

Ruby already has command to sync your rails application with mysql, you can use the following command to sync your database with model.

rake db:migrate

Sometimes you need to create your database manually by using following command.

create database buffercode_development;
grant all privileges on buffecode_development to 'root'@'localhost' identified by '123';
FLUSH PRIVILEGES;

Do same for other databases, or rake db:migrate will give you error.

You can view your Rails with Mysql Configuration under work/buffercode/config/database.yml as shown in below image
ROR Tutorial : Rails with Mysql Configuration

Have something to add or still stuck somewhere ?? share it in comments .

Follow us on Facebook, Google Plus and Twitter.

Previous                                   Next