0

I am working on windows rails application . I have created rb file for that application.

I am able to connect to mysql via appliction but when I am trying to connect it via ruby code , error is coming for connecting mysql. I am working on the production mode .

Running production mode rails application openning the mysql connection but not rb file out of application . I am using database.yml to connect th mysql.

This system is working fine on the windows xp but not on windows 7 Here is a code

require "yaml"
require 'mysql2'
config = YAML::load_file("config/database.yml")["production"]
client = Mysql2::Client.new(config)

Here is the error

Mysql2::Error: Can't connect to MySQL server on 'localhost' (10061)
Arpit Vaishnav
  • 4,739
  • 6
  • 39
  • 57

1 Answers1

0

Try changing your database.yml config file and add host: 127.0.0.1

 development:
   adapter: mysql2
   database: db/development.mysql2
   pool: 5
   host: 127.0.0.1
dimitrisk
  • 774
  • 9
  • 15