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)
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.