简体   繁体   English

Rails无法连接到'localhost'上的MySQL服务器

[英]Rails Can't connect to MySQL server on 'localhost'

I'm having no end of trouble with my Rails 3 app's Mysql connection, though I have studied countless relevant threads. 虽然我研究了无数相关的线程,但我对Rails 3应用程序的Mysql连接没有任何麻烦。 My error message: 我的错误信息:

C:/Ruby193/lib/ruby/gems/1.9.1/gems/mysql2-0.3.11-x86-mingw32/lib/mysql2/client.rb:44:in `connect': Can't connect to MySQL server on 'localhost' (10061) (Mysql2::Error)

(Before you flag this as a duplicate question, consider whether you can find another thread with pertinent advice I have not followed.) (在将此标记为重复问题之前,请考虑是否可以找到另一个我没有遵循的相关建议的主题。)

My efforts thus far: 到目前为止我的努力:

I have copied the libmysql.dll file from <mysql installation>/bin to <ruby installation>/bin . 我已将libmysql.dll文件从<mysql installation>/bin复制到<ruby installation>/bin

I have the mysql2 gem in the bundle, and it was installed with the connector ( --with-mysql-dir=C:/mysql-connector-c-noinstall-6.0.2-win32 ): 我在bundle中有mysql2 gem,它与连接器一起安装( --with-mysql-dir=C:/mysql-connector-c-noinstall-6.0.2-win32 ):

> bundle show mysql2
C:/Ruby193/lib/ruby/gems/1.9.1/gems/mysql2-0.3.11-x86-mingw32

I believe my database.yml file is configured correctly: 我相信我的database.yml文件配置正确:

development:
  adapter: mysql2
  encoding: utf8
  reconnect: false
  database: tq_development
  pool: 5
  username: root
  password: pinney
  host: localhost

尝试用127.0.0.1替换localhost(在workbench和yml中)

你有没有在有问题的项目上运行rake db:create?

I agree with the above....Make sure it works with workbench or some other GUI tool and you can connect using the info the database.yml file. 我同意上述内容....确保它适用于工作台或其他一些GUI工具,您可以使用info连接database.yml文件。

If not....come back and give us another holler. 如果不是......回来给我们另一个叫喊声。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM