Rails 应用程序无法通过命名管道/套接字连接到本地 MySQL 服务器 --- Windows 7 x64
我正在尝试设置一个 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 rubygem 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: rootpassword: **********
host: localhost
socket: mysqltest:
adapter: mysql2
encoding: utf8 reconnect: false
database: application_test
pool: 5
username: rootpassword: **********
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_ciCan'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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试在 database.yml 中添加以下参数来指定端口号:
Try to specify the port number in your database.yml adding this parameter: