简体   繁体   中英

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. 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 .

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 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:

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.

If not....come back and give us another holler.

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.

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