简体   繁体   English

无法使Rails,MAMP,mysql2一起工作

[英]Can't get Rails, MAMP, mysql2 to work together

I'm currently trying to get the following to work together, to no avail: 我目前正在尝试使以下各项协同工作,但无济于事:

Rails 3.1.1 MAMP 2.0.2 mysql2 5.5.9 Ruby 1.9.2 Mac OSX 10.7 (lion) Rails 3.1.1 MAMP 2.0.2 mysql2 5.5.9 Ruby 1.9.2 Mac OSX 10.7(狮子)

Everything appears installed.. mysql2 and rails show up in my gem list. 一切似乎已安装.. mysql2和rails显示在我的gem列表中。 I used the instructions found here to install mysql2 and it seemed to go smoothly: 我使用此处找到的说明安装mysql2,它似乎运行顺利:

http://blog.mirotin.net/35/mamp-1-9-5-mysql-5-5-9-and-ruby-mysql2 http://blog.mirotin.net/35/mamp-1-9-5-mysql-5-5-9-and-ruby-mysql2

I've also specified the MAMP socket in my database.yml file: socket: /Applications/MAMP/tmp/mysql/mysql.sock 我还在我的database.yml文件中指定了MAMP套接字:套接字:/Applications/MAMP/tmp/mysql/mysql.sock

My rails application runs fine with sqlite3, but when I change database to mysql2 and try to run webrick, I get a generic ActiveRecord::ConnectionNotEstablished (ActiveRecord::ConnectionNotEstablished) message. 我的rails应用程序在sqlite3上运行良好,但是当我将数据库更改为mysql2并尝试运行webrick时,我收到一条通用的ActiveRecord :: ConnectionNotFounded(ActiveRecord :: ConnectionNotFounded)消息。

What am I missing? 我想念什么?

You have to downgrade to mysql 5.1. 您必须降级到mysql 5.1。 I had the same problem. 我有同样的问题。 Then you need to install the mysql2 gem with the following command: 然后,您需要使用以下命令安装mysql2 gem:

env ARCHFLAGS="-arch x86_64" gem install --no-rdoc --no-ri mysql2 -- --with-mysql-config=/usr/local/mysql/bin/mysql_config

Also, you may want to try replacing gem 'mysql2' with gem 'mysql2', '< 0.3' 另外,您可能希望尝试将gem 'mysql2'替换为gem 'mysql2', '< 0.3'

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

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