IM苦苦連接到我的mysql服務在我的本地Windows 7運行的機器嘗試通過Web瀏覽器的不能從導軌連接到MySQL
Mysql2::Error (Can't connect to MySQL server on 'localhost' (10061)):
耙遷移或訪問時,我收到以下錯誤我已經離開了MySQL的用戶名/密碼爲默認值 - 這是我的YAML的conf文件
# MySQL. Versions 4.1 and 5.0 are recommended.
#
# Install the MYSQL driver
# gem install mysql2
#
# Ensure the MySQL gem is defined in your Gemfile
# gem 'mysql2'
#
# And be sure to use new-style password hashing:
# http://dev.mysql.com/doc/refman/5.0/en/old-client.html
development:
adapter: mysql2
port: 3306
encoding: utf8
reconnect: false
database: events_development
pool: 5
username: root
password:
host: localhost
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
adapter: mysql2
encoding: utf8
reconnect: false
database: events_test
pool: 5
username: root
password:
host: localhost
production:
adapter: mysql2
encoding: utf8
reconnect: false
database: events_production
pool: 5
username: root
password:
host: localhost
的事情是我可以用root通過命令行上的MySQL,也貫穿xampp- phpmyadmin的登錄,所以我已經把範圍到防火牆的問題?或權限問題?一切都在我的機器
更新
我打開Windows防火牆關閉上運行的本地主機,它並沒有區別
重新啓動機和服務器沒有爲我工作...在我發現到底ruby/rails無法將localhost解析爲ip(127.0.0.1)。我用config/database.yml文件中的ip替換localhost,錯誤消失了! – Zeeshan
問題是因爲如果您在Windows 7上啓用了IPv6網絡連接,則localhost會解析爲「:: 1」。您可以通過在命令提示符處運行'ping localhost'來驗證,結果應該是'Reply from :: 1:time <1ms'。而mysql通常配置爲127.0.0.1綁定地址。 – Zeeshan