简体   繁体   English

Ruby on Rails:MySql Gem不起作用:未初始化的常量Mysql :: Error

[英]Ruby on Rails: MySql Gem does not work: uninitialized constant Mysql::Error

I have the following installed: Mac Os 10.7.2 (MacPro Pro, Processor Core i7) rails 3.1.0 ruby 1.9.2 mysql 5.5.19, for osx10.6 (i386) 我安装了以下软件:Mac OS 10.7.2(MacPro Pro,Processor Core i7)rails 3.1.0 ruby​​ 1.9.2 mysql 5.5.19,for osx10.6(i386)

I can install the mysql gem without problems: sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config 我可以毫无问题地安装mysql gem:sudo env ARCHFLAGS =“-arch x86_64” gem install mysql---with-mysql-config = / usr / local / mysql / bin / mysql_config

I can also login and create a database and a dummy table. 我还可以登录并创建数据库和虚拟表。

But when I want to set up the mysql db using rake rake db:setup RAILS_ENV="production" --trace Then I receive the following error: uninitialized constant Mysql::Error 但是,当我想使用rake rake db:setup RAILS_ENV =“ production” --trace设置mysql db时,我收到以下错误:未初始化的常量Mysql :: Error

Is it possible that the MySQL version is wrongly installed? MySQL版本是否可能安装错误? I used the "Mac OS X ver. 10.6 (x86, 64-bit)", but when I run mysql -V then it says "i386". 我使用了“ Mac OS X版本10.6(x86,64位)”,但是当我运行mysql -V时,它会显示“ i386”。 Isn't this the 32 bit version? 这不是32位版本吗? The full output is: Ver 14.14 Distrib 5.5.19, for osx10.6 (i386) using readline 5.1 完整的输出是:使用readline 5.1的osx10.6(i386)的Ver 14.14 Distrib 5.5.19

Did you run bundle install ? 您是否运行了bundle install Also rather than the old mysql gem, it is recommended to use the mysql2 gem. 另外,建议使用mysql2 gem,而不是旧的mysql gem。

And then when you are inside your project's root directory, run your app using bundler: 然后,当您位于项目的根目录中时,请使用bundler运行应用程序:

bundle exec rails s

When you use bundle, you don't need to install gems using gem install ... , just use bundle install . 使用bundle时,您不需要使用gem install ...安装gem,只需使用bundle install

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

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