gpt4 book ai didi

ruby-on-rails - Rails应用程序无法通过命名管道/套接字连接到本地MySQL服务器— Windows 7 x64

转载 作者:行者123 更新时间:2023-12-03 11:56:13 24 4
gpt4 key购买 nike

我正在尝试设置一个Rails应用程序,以便在我的本地计算机上使用MySQL服务器进行开发。我已经针对MySQLConnector/C成功编译了mysql2 gem;尽管我在安装MySQL Server时使用 bundle 的libmysql.dll收到了相同的错误。当我尝试rake db:create时,应用程序无法连接到MySQL Server。

MySQL在我的机器上配置为Windows服务,并通过命名管道自动启动以进行仅限本地的连接; TCP-IP已被完全禁用。我的my.ini文件中的套接字名称是mysql

我的Rails应用程序的database.yml文件看起来像这样:

development:
adapter: mysql2
encoding: utf8 reconnect: false
database: application_dev
pool: 5
username: root

password: **********

host: localhost
socket: mysql

test:
adapter: mysql2
encoding: utf8 reconnect: false
database: application_test pool: 5
username: root

password: **********

host: localhost
socket: mysql



我收到的错误是:

D:\Dropbox\Programming\Ruby\application>rake db:create (in D:/Dropbox/Programming/Ruby/application) Can't connect to MySQL server on 'localhost' (10061) Couldn't create database for {"adapter"=>"mysql2", "encoding"=>"utf8", "reconnect"=>false, "database"=>"application_test", "pool"=>5, "username"=>"root", "password"=>"**********", "host"=>"localhost", " socket"=>"mysql"}, charset: utf8, collation: utf8_unicode_ci

Can't connect to MySQL server on 'localhost' (10061) Couldn't create database for {"adapter"=>"mysql2", "encoding"=>"utf8", "reconnec t"=>false, "database"=>"applicaton_dev", "pool"=>5, "username"=>"root", "password "=>"**********", "host"=>"localhost", "socket"=>"mysql"}, charset: utf8, collation: utf8_unicode_ci



我正在使用Windows 7 Home Premium 64位和以下Ruby/Rails/MySQL发行版:
ruby 1.9.2p180 (2011-02-18) [i386-mingw32] Rails 3.0.7 mysql2 rubygem 0.2.7 mysql Ver 14.14 Distrib 5.5.11, for Win32 (x86) mysql Connector/C 6.0.0
我尝试过重新安装MySQL Server并启用TCP-IP连接,它只是挂起而不是失败。

最佳答案

尝试在您的database.yml中指定端口号,并添加以下参数:

port: 3306 (or whatever your mysql port has)

关于ruby-on-rails - Rails应用程序无法通过命名管道/套接字连接到本地MySQL服务器— Windows 7 x64,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5824700/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com