简体   繁体   English

使Ruby和MySQL协同工作

[英]Getting Ruby and MySQL to work together

I'm trying to install ROR with a MySQL backend on a Windows 7 x64 box but they are not working together. 我正在尝试在Windows 7 x64机器上安装带有MySQL后端的ROR,但它们无法一起使用。 When I did this before several months ago, it was just a mysql install and a bundle command but not this time. 几个月前我这样做时,这只是一个mysql安装和bundle命令,但这次不是。

I've installed MySQL 5.1 32 bit on a path with no spaces and configured the server. 我在没有空格的路径上安装了MySQL 5.1 32位,并配置了服务器。 I had to install the mysql2 gem using the command line arguments to specify the mysql instance path to get the gem to install. 我必须使用命令行参数来安装mysql2 gem,以指定mysql实例路径来获取要安装的gem。 However, rake db:create fails with a Can't connect to MySQL server on 'localhost' (10061) error. 但是,rake db:create失败, Can't connect to MySQL server on 'localhost' (10061)错误。

I have verifed that mysql is running on the specified port. 我已验证mysql在指定端口上运行。 mysql, mysqladmin, and telnet localhost 3306 all work as normal. mysql,mysqladmin和telnet localhost 3306都可以正常工作。 I have a firewall exception for port 3306 and it works fine. 我有端口3306的防火墙例外,并且工作正常。 I've also turned the firewall off and it makes no difference. 我还关闭了防火墙,这没有什么区别。

I've spent hours going though google and trying many possibilities without success. 我已经花了几个小时通过Google,尝试了许多成功的尝试。 Most of the documentation I have found relates to issues where mysql is not running / running on a pipe but this is not my problem. 我发现的大多数文档都涉及mysql未运行/在管道上运行的问题,但这不是我的问题。

database.yml excerpt:
common: &common
  adapter: mysql2
  encoding: utf8
  reconnect: false
  pool: 5
  username: root
  password: root
  #host: 127.0.0.1
  host: localhost
  port: 3307


development:
  <<: *common
  database: project_dev

Any ideas how to fix this? 任何想法如何解决这一问题?

From the mysql2 page on GitHub , you may have a missing configuration line in your Gemfile, depending on your version of ActiveRecord. 在GitHub上mysql2页面上 ,您的Gemfile中可能缺少配置行,具体取决于您的ActiveRecord版本。

NOTE: as of 0.3.0, and ActiveRecord 3.1 - the ActiveRecord adapter has been pulled out of this gem and into ActiveRecord itself. 注意:从0.3.0开始,从ActiveRecord 3.1开始-ActiveRecord适配器已从此gem中拉出,并进入ActiveRecord本身。 If you need to use mysql2 with Rails versions < 3.1 make sure and specify gem "mysql2", "~> 0.2.7" in your Gemfile 如果您需要将MySQL2与Rails版本<3.1一起使用,请确保在Gemfile中指定gem“ mysql2”,“〜> 0.2.7”

Hope that helps. 希望能有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM