Rake db:create uninitialized constant Mysql::Error

I have yet to find a solution for this issue I have tried multiple
things that I have found on google, but yet have i found a solution. If
someone could help me and point me in the right direction I would be
much appreciated.

Thanks.

rake aborted!
uninitialized constant Mysql::Error

** Invoke db:create (first_time)
** Invoke db:load_config (first_time)
** Invoke rails_env (first_time)
** Execute rails_env
** Execute db:load_config
** Execute db:create
rake aborted!
uninitialized constant Mysql::Error
/Library/Ruby/Gems/1.8/gems/activerecord-3.0.0.beta2/lib/active_record/railties/databases.rake:68:in
create_database' /Library/Ruby/Gems/1.8/gems/activerecord-3.0.0.beta2/lib/active_record/railties/databases.rake:33 /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:incall’
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in execute' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:ineach’
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in execute' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:597:ininvoke_with_call_chain’
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/monitor.rb:242:in
synchronize' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:ininvoke_with_call_chain’
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:583:in invoke' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2051:ininvoke_task’
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in top_level' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:ineach’
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in top_level' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:instandard_exception_handling’
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2023:in top_level' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2001:inrun’
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in
standard_exception_handling' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:1998:inrun’
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/bin/rake:31
/usr/bin/rake:19:in `load’
/usr/bin/rake:19

On Sun, Apr 11, 2010 at 4:19 PM, Michael Michael
[email protected]wrote:

/Library/Ruby/Gems/1.8/gems/activerecord-3.0.0.beta2/lib/active_record/railties/databases.rake:68:in
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/monitor.rb:242:in
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2023:in top_level' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2001:in run’
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in
standard_exception_handling' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:1998:in run’
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/bin/rake:31
/usr/bin/rake:19:in `load’
/usr/bin/rake:19

Michael, you’ll need to add mysql to your Gemfile.

Good luck,

-Conrad

Post up the output of this command:
gem list

my gem file already has it, any other solutions? I just decided to do
the package install of mysql to see if i was manually installing it
wrong, and nope same issue still.

source ‘http://rubygems.org

gem ‘rails’, ‘3.0.0.beta2’

Bundle edge Rails instead:

gem ‘rails’, :git => ‘git://github.com/rails/rails.git’

gem ‘mysql’

Use unicorn as the web server

gem ‘unicorn’

Deploy with Capistrano

gem ‘capistrano’

Bundle the extra gems:

gem ‘bj’

gem ‘nokogiri’, ‘1.4.1’

gem ‘sqlite3-ruby’, :require => ‘sqlite3’

gem ‘aws-s3’, :require => ‘aws/s3’

Bundle gems for certain environments:

gem ‘rspec’, :group => :test

group :test do

gem ‘webrat’

end

On Sun, Apr 11, 2010 at 5:28 PM, Michael Michael
[email protected]wrote:

my gem file already has it, any other solutions? I just decided to do
the package install of mysql to see if i was manually installing it
wrong, and nope same issue still.

Michael, did you run the following in the root of your Rails
application:

bundle install

-Conrad

Yes I did, I kind of gave up for now on this. I can’t seem to figure it
out.

If you could or anyone could help me out would be great.

Thanks again for the response.

Conrad T. wrote:

On Sun, Apr 11, 2010 at 5:28 PM, Michael Michael
[email protected]wrote:

my gem file already has it, any other solutions? I just decided to do
the package install of mysql to see if i was manually installing it
wrong, and nope same issue still.

Michael, did you run the following in the root of your Rails
application:

bundle install

-Conrad

John Grimes wrote:

Post up the output of this command:
gem list

*** LOCAL GEMS ***

abstract (1.0.0)
actionmailer (3.0.0.beta2, 2.3.5, 2.2.2, 1.3.6)
actionpack (3.0.0.beta2, 2.3.5, 2.2.2, 1.13.6)
actionwebservice (1.2.6)
activemodel (3.0.0.beta2)
activerecord (3.0.0.beta2, 2.3.5, 2.2.2, 1.15.6)
activeresource (3.0.0.beta2, 2.3.5, 2.2.2)
activesupport (3.0.0.beta2, 2.3.5, 2.2.2, 1.4.4)
acts_as_ferret (0.4.4, 0.4.3)
arel (0.3.3)
builder (2.1.2)
bundler (0.9.18)
capistrano (2.5.18, 2.5.2)
cgi_multipart_eof_fix (2.5.0)
daemons (1.0.10)
dnssd (0.6.0)
erubis (2.6.5)
fastthread (1.0.1)
fcgi (0.8.7)
ferret (0.11.6)
gem_plugin (0.2.3)
highline (1.5.2, 1.5.0)
hpricot (0.6.164)
i18n (0.3.6)
libxml-ruby (1.1.2)
mail (2.2.0, 2.1.5.3)
memcache-client (1.8.2)
mime-types (1.16)
mongrel (1.1.5)
mysql (2.8.1)
needle (1.3.0)
net-scp (1.0.2, 1.0.1)
net-sftp (2.0.4, 2.0.1, 1.1.1)
net-ssh (2.0.21, 2.0.4, 1.1.4)
net-ssh-gateway (1.0.1, 1.0.0)
polyglot (0.3.1)
rack (1.1.0, 1.0.1)
rack-mount (0.6.1)
rack-test (0.5.3)
rails (3.0.0.beta2, 2.3.5, 2.2.2, 1.2.6)
railties (3.0.0.beta2)
rake (0.8.7, 0.8.3)
RedCloth (4.1.1)
ruby-openid (2.1.7, 2.1.2)
ruby-yadis (0.3.4)
rubygems-update (1.3.6)
rubynode (0.1.5)
sqlite3-ruby (1.2.4)
termios (0.9.4)
text-format (1.0.0)
text-hyphen (1.0.0)
thor (0.13.4)
treetop (1.4.5)
tzinfo (0.3.19)
xmpp4r (0.5, 0.4)

I had similar problem after upgrading to Snow leopard, i had to
reinstall the Mysql gem with right architecture flags.

Michael Michael wrote:

I have yet to find a solution for this issue I have tried multiple
things that I have found on google, but yet have i found a solution. If
someone could help me and point me in the right direction I would be
much appreciated.

Thanks.

you need reinstall mysql gems with correct flags. Try google this :
mysql
gems flags snow leopard

Michael^2,

I have faced the same problem, and here is how I solved it, with the
list of failures. Note that I have faced the problem only once on this
particular configuration. Elsewhere (PPC and x86_64) the world is
cloudless.

Configuration:

  • OS: Fedora 12
  • Arch: PPC64
  • Rails 3 pre
  • Gem 1.3.6
  • Ruby 1.8.8 (I use 1.8.7 on my other machines, but I needed some
    extra patches to compile against openssl 1.0—yet another story :stuck_out_tongue: )

(Fail 1) Installed the gem with Bundler
(Fail 2) Installed the gem with gem, and bundle it with Bundler
(Fail 3) Installed the library manually

Given that my repository assumes we use Bundler, I then did again
(Fail 1). This is the configuration that will work in the following…

At this point, I started to go along the new Rails bootstrap process.
Playing also with IRB (rails c) and Rake, I realized that the gems
are all loaded but mysql. The most interesting:

$ rake db:setup --trace #=> Fail
$ rake -r mysql db:setup --trace #=> Success, although all Mysql
constants are flagged as already initialized…

Which confirms a weird behavior with the load process for the mysql
gem, on that particular architecture.

In the Gemfile, I have then bypassed Gem to load the mysql library
directly:

Database

#gem ‘mysql’
require ‘mysql’

Doing so everything works fine now. I would like to understand what is
happening but I am a bit short in time now :frowning: Note that this
modification of the Gemfile is not what we want on all machines. Given
that this PPC64 machine is my production server, a simple conditional
to choose between gem or require may be sufficient, waiting for a
proper fix.

I hope this can help you, but I have a rare architecture these days…
Not sure it is applicable directly.

Eric

I faced this problem too, if you have installed MYSQL 5.5 you should
uninstall and install MYSQL 5.1 . I just left a blog post about this :
http://geryit.com/blog/2011/01/installing-mysql-with-rails-on-mac-os-x-snow-leopard/