0

I want to establish_connection to database on other machine:

require 'mysql2'
require "active_record"

Using ActiveRecord

ActiveRecord::Base.establish_connection(
:adapter=> 'mysql2',
:database=> 'development_db',
:host=> "192.168.1.135",
:port=> "3306",
:username=> 'username',
:password=>'password'
)

get following error : Can't connect to MySQL server on '192.168.1.135' (111) (Mysql2::Error)

dr. strange
  • 665
  • 7
  • 22

1 Answers1

0

After too much hard work i found following was configuration missing to connect remote datadase.

  1. Add following lines to my.cnf in mysqld section

    bind-address = 0.0.0.0

  2. Restart mysql service

  3. run following commands(create new user and password)

    GRANT ALL ON database_name.* TO u_name@'202.54.10.20' IDENTIFIED BY 'PASSWORD';

    FLUSH PRIVILEGES;

dr. strange
  • 665
  • 7
  • 22