简体   繁体   English

耙子流产了!未初始化的常量Mysql2

[英]rake aborted! uninitialized constant Mysql2

Goksel-Eryigits-Mac-mini:blog geryit$ rake db:migrate --trace
(in /Users/geryit/Sites/blog)
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:migrate
rake aborted!
Client does not support authentication protocol requested by server; consider upgrading MySQL client
/Users/geryit/.rvm/rubies/ruby-1.8.7-p330/lib/ruby/1.8/mysql.rb:453:in `read'
/Users/geryit/.rvm/rubies/ruby-1.8.7-p330/lib/ruby/1.8/mysql.rb:130:in `real_connect'
/Users/geryit/.rvm/gems/ruby-1.8.7-p330/gems/activerecord-3.0.3/lib/active_record/connection_adapters/mysql_adapter.rb:600:in `connect'
/Users/geryit/.rvm/gems/ruby-1.8.7-p330/gems/activerecord-3.0.3/lib/active_record/connection_adapters/mysql_adapter.rb:164:in `initialize
.
.
.

database.yml database.yml的

development:
  adapter: mysql
  encoding: utf8
  database: test
  pool: 5
  username: root
  password:
  socket: /tmp/mysql.sock

Have you defined 你定义了吗?

gem 'mysql2'

in Gemfile? 在Gemfile中? For Rails 3 and Bundler, it's not enough to install the gem, but to include it in Gemfile. 对于Rails 3和Bundler,安装gem是不够的,但要将它包含在Gemfile中。

They work together now without any problems. 他们现在一起工作没有任何问题。 The problem was Mysql version and mysql gem flags. 问题是Mysql版本和mysql gem标志。 I removed MYSQL 5.5 and installed Mysql 5.1 back. 我删除了MYSQL 5.5并重新安装了Mysql 5.1。 Everything is fixed. 一切都是固定的。 Thanks. 谢谢。

I wrote a blog post about installing, it can be helpful : https://geryit.com/blog/installing-mysql-with-rails-on-mac-os-x-snow-leopard/ 我写了一篇关于安装的博客文章,它可能会有所帮助: https//geryit.com/blog/installing-mysql-with-rails-on-mac-os-x-snow-leopard/

Try uninstalling the mysql gem. 尝试卸载mysql gem。 It might be conflicting with the mysql2 gem you're using in your database.yml . 它可能与您在database.yml使用的mysql2 gem相冲突。

我在Snow Leopard和Rails 3上获得了“未初始化的常量Mysql”。在Gemfile中添加“mysql”gem为我修复了它。

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

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