[英]Ruby on Rails server connection error
我是紅寶石新手。 並嘗試與mysql服務器連接。 我嘗試與沼澤連接,但是沒有用。 現在我只是將libmsql.dll文件復制到我的ruby bin目錄中。 但是我仍然無法連接服務器。 這是錯誤消息。 誰能告訴我怎么了?
Microsoft Windows [Version 6.1.7600] Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\row>cd dev
C:\row\dev>dir
Volume in drive C has no label.
Volume Serial Number is F223-E79C
Directory of C:\row\dev
09/27/2016 04:02 AM <DIR> .
09/27/2016 04:02 AM <DIR> ..
09/27/2016 04:03 AM <DIR> mysql_test
0 File(s)
0 bytes
3 Dir(s)
37,122,785,280 bytes free
C:\row\dev>cd mysql_test
C:\row\dev\mysql_test>ruby test.rb
C:/row/Ruby22/lib/ruby/gems/2.2.0/gems/mysql2-0.4.4-x86-mingw32/lib/mysql2/clien t.rb:87:in `connect': Can't connect to MySQL server on 'localhost' (10061) (Mysq l2::Error)
from C:/row/Ruby22/lib/ruby/gems/2.2.0/gems/mysql2-0.4.4-x86-mingw32/lib /mysql2/client.rb:87:in `initialize'
from test.rb:3:in `new'
from test.rb:3:in `<main>'
C:\row\dev\mysql_test>
要將mysql DB連接到rails中,您必須對配置文件config/database.yml
進行一些更改。
您必須安裝gem,然后連接到mysql DB。
production:
adapter: mysql2
encoding: utf8
database: example
pool: 10
username: example
password: secure
socket: /var/run/mysqld/mysqld.sock
reconnect: true
除此之外,您還必須進行以下更改
gem 'mysql2'
並運行bundle install
。
參考:這是有關如何將mysql DB連接到我們的rails應用程序的非常清晰的解釋。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.