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

发布于 2024-11-03 23:03:17 字数 1897 浏览 0 评论 0原文

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

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

我的 Rails 应用程序的 database.yml 文件如下所示:

开发:
适配器:mysql2
编码:utf8 重新连接:false
数据库:application_dev
池:5
用户名:root

密码:************

主机:本地主机
套接字:mysql

测试:
适配器:mysql2
编码:utf8 重新连接:false
数据库:application_test 池:5
用户名:root

密码:************

主机:本地主机
套接字:mysql

我收到的错误是:

D:\Dropbox\Programming\Ruby\application>rake db:create (在 D:/Dropbox/Programming/Ruby/application 中) 无法连接到“localhost”上的 MySQL 服务器 (10061) 无法为 {"adapter"=>"mysql2", "encoding"=>"utf8", "reconnect"=>false, "database"=>"application_test", "pool"=> 创建数据库;5、“用户名”=>“root”、“密码”=>“************”、“主机”=>“localhost”、“ socket"=>"mysql"},字符集:utf8,排序规则:utf8_unicode_ci

无法连接到“localhost”上的 MySQL 服务器 (10061) 无法为 {"adapter"=>"mysql2", "encoding"=>"utf8", "reconnec" 创建数据库 t"=>false, "database"=>"applicaton_dev", "pool"=>5, "username"=>"root", "password "=>"*********"、"host"=>"localhost"、"socket"=>"mysql"},字符集:utf8,排序规则: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 ruby​​gem 0.2.7

mysql Ver 14.14 Distrib 5.5.11,用于 Win32 (x86)

mysql Connector/C 6.0.0

我已经尝试过重新安装 MySQL 服务器并启用 TCP-IP 连接,它只是挂起而不是失败。

I'm trying to set up a Rails application to use a MySQL server on my local machine for development. I have successfully compiled the mysql2 gem against MySQLConnector/C; although I have received the same error using libmysql.dll bundled with my installation of MySQL Server. When I attempt to rake db:create, the application fails to connect to the MySQL Server.

MySQL is configured on my machine as a Windows service, started automatically for local-only connections through named-pipes; TCP-IP has been completely disabled. The name of the socket in my my.ini file is mysql.

My database.yml file for my Rails application looks something like this:

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

And the error I'm recieving is:

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

I'm using Windows 7 Home Premium 64-bit with the following Ruby/Rails/MySQL distribution:

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

I've tried reinstalling MySQL Server and enabling TCP-IP connections, and it just hangs instead of failing.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

国粹 2024-11-10 23:03:23

尝试在 database.yml 中添加以下参数来指定端口号:

port: 3306 (or whatever your mysql port has)

Try to specify the port number in your database.yml adding this parameter:

port: 3306 (or whatever your mysql port has)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文