I am working on windows rails application . I have created rb file for that application.
我正在开发windows rails应用程序。我为该应用程序创建了rb文件。
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 .
我可以通过应用程序连接到mysql,但当我尝试通过ruby代码连接它时,错误即将连接mysql。我正在制作生产模式。
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.
运行生产模式rails应用程序打开mysql连接但不是rb文件退出应用程序。我正在使用database.yml来连接mysql。
This system is working fine on the windows xp but not on windows 7 Here is a code
这个系统在windows xp上工作正常但在windows 7上没有。这是一个代码
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)
1 个解决方案
#1
0
Try changing your database.yml
config file and add host: 127.0.0.1
尝试更改database.yml配置文件并添加host:127.0.0.1
development:
adapter: mysql2
database: db/development.mysql2
pool: 5
host: 127.0.0.1
#1
0
Try changing your database.yml
config file and add host: 127.0.0.1
尝试更改database.yml配置文件并添加host:127.0.0.1
development:
adapter: mysql2
database: db/development.mysql2
pool: 5
host: 127.0.0.1