This project is archived and is in readonly mode.
rake db:create problem in rails3 with mysql2
-
Neeraj Singh
- State changed from new to open
- Tag set to rails 3, activerecord
- Importance changed from to Low
Attached is a code patch. Can you try and see if it fixes your problem.
-
Marjan Krekoten'
I have another patch which addresses this issue and also nonexistent Mysql::Error#error method. It also deals with situation when we use old mysql gem and 'uninitialized constant Mysql2' message gets raised.
-
rdinca
I can confirm Marjan Krekoten' s patch is working for me ( haven't tried the other one ), but it is rather unpleasant having to modifing database.rake... perhaps the patch should be included into rails right away, not forcing mysql users to hack into activerecord files.
-
Marjan Krekoten'
- Assigned user set to José Valim
-
José Valim
- Milestone cleared.
- Assigned user changed from José Valim to Brian Lopez
- Importance changed from Low to Medium
Brian, do you think we can make MySQL2 error have the same API as MySQL one and do a small release?
-
Marjan Krekoten'
I agree with José Valim. It probably would be better to do somthing like this
class Mysql2::Error # ... alias_method :errno, :error_number alias_method :error, :message endBut following is still needed, because it avoids 'uninitialized constant Mysql2' when we use mysql instead of mysql2:
error_class = "#{config['adapter'].capitalize}::Error".constantizeI can edit this patch and also make patch for mysql2 if José Valim and Brian Lopez agree with this.
-
Brian Lopez
Hey guys,
I added the aliases here: http://github.com/brianmario/mysql2/commit/98fbeb6f64e562e9889346d4... -
Marjan Krekoten'
Cool! I've updated patch to fix 'uninitialized constant Mysql2'. But this problem will go away completely with new release of mysql2 gem.
-
Brian Lopez
I'll try and push 0.2.4 by tonight
-
jw
Is there a non hacky way for a rails mortal like me to resolve this problem? I have updated to rails 3 today and have since not been able to do any development. Thanks.
-
Bison
Any progress on this issue? I'm new to Rails and (like jw) this has held me up for almost a week now. Is there an easy workaround? Thanks.
-
Marjan Krekoten'
Well we need to wait for next release of mysql2. It will introduce compatibility with mysql gem. Or you can point your Gemfile to mysql2 git repo.
-
Marjan Krekoten'
mysql2 v0.2.4 released with mysql compatibility fix. So I think we should update development and generated Gemfile to use >= 0.2.4. I've attached a patch.
-
Ryan Bigg
- Tag changed from rails 3, sheepskin boots, activerecord to activerecord rails 3
Automatic cleanup of spam.
-
Rohit Arondekar
Currently the Gemfile uses 0.2.6. The rest hasn't been applied yet. Was the issue resolved?
-
Santiago Pastorino
- State changed from open to resolved
I have talked with Brian and this is resolved now. If somebody has still some kind of trouble with this, please comment here and I will reopen it.
-
John
Hi, I'm running rails 3.0.3, ruby 1.9.2p0, mysql 5.1.53, and when i run rake db:create I get the following:
** 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 /Users/John/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.0.1/lib/rspec/core/backward_compatibility.rb:20:in `const_missing' /Users/John/.rvm/gems/ruby-1.9.2-p0/gems/rspec-expectations-2.0.1/lib/rspec/expectations/backward_compatibility.rb:6:in `const_missing' /Users/John/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.3/lib/active_record/railties/databases.rake:64:in `rescue in create_database' /Users/John/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.3/lib/active_record/railties/databases.rake:39:in `create_database' /Users/John/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.3/lib/active_record/railties/databases.rake:33:in `block (2 levels) in <top (required)>' /Users/John/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.8.7/lib/rake.rb:636:in `call' /Users/John/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.8.7/lib/rake.rb:636:in `block in execute' /Users/John/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.8.7/lib/rake.rb:631:in `each' /Users/John/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.8.7/lib/rake.rb:631:in `execute' /Users/John/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.8.7/lib/rake.rb:597:in `block in invoke_with_call_chain' /Users/John/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize' /Users/John/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain' /Users/John/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.8.7/lib/rake.rb:583:in `invoke' /Users/John/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.8.7/lib/rake.rb:2051:in `invoke_task' /Users/John/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.8.7/lib/rake.rb:2029:in `block (2 levels) in top_level' /Users/John/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.8.7/lib/rake.rb:2029:in `each' /Users/John/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.8.7/lib/rake.rb:2029:in `block in top_level' /Users/John/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling' /Users/John/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.8.7/lib/rake.rb:2023:in `top_level' /Users/John/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.8.7/lib/rake.rb:2001:in `block in run' /Users/John/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling' /Users/John/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.8.7/lib/rake.rb:1998:in `run' /Users/John/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.8.7/bin/rake:31:in `<top (required)>' /Users/John/.rvm/gems/ruby-1.9.2-p0/bin/rake:19:in `load' /Users/John/.rvm/gems/ruby-1.9.2-p0/bin/rake:19:in `<main>'My gems are:
*** LOCAL GEMS *** abstract (1.0.0) actionmailer (3.0.3, 3.0.0) actionpack (3.0.3, 3.0.0) activemodel (3.0.3, 3.0.0) activerecord (3.0.3, 3.0.0) activeresource (3.0.3, 3.0.0) activesupport (3.0.3, 3.0.0) addressable (2.2.2) arel (2.0.6, 1.0.1) bcrypt-ruby (2.1.2) builder (2.1.2) bundler (1.0.2) cgi_multipart_eof_fix (2.5.0) configuration (1.2.0, 1.1.0) cucumber (0.10.0, 0.9.3) cucumber-rails (0.3.2) daemons (1.1.0, 1.0.10) database_cleaner (0.6.0) devise (1.1.5, 1.1.3) diff-lcs (1.1.2) erubis (2.6.6) faraday (0.5.3) fastthread (1.0.7) gem_plugin (0.2.3) gherkin (2.3.2, 2.2.9) i18n (0.5.0, 0.4.1) jasmine (1.0.1.1, 1.0.1) json (1.4.6) json_pure (1.4.6) launchy (0.3.7) mail (2.2.12, 2.2.7) mime-types (1.16) mongrel (1.2.0.pre2) multi_json (0.0.5) multipart-post (1.0.1) mysql2 (0.2.6) net-ldap (0.1.1) nokogiri (1.4.4, 1.4.3.1) oa-basic (0.1.6) oa-core (0.1.6) oa-enterprise (0.1.6) oa-oauth (0.1.6) oa-openid (0.1.6) oauth (0.4.4) oauth2 (0.1.0) omniauth (0.1.6) pg (0.9.0) polyglot (0.3.1) pyu-ruby-sasl (0.0.3.2) rack (1.2.1) rack-mount (0.6.13) rack-openid (1.2.0) rack-test (0.5.6) rails (3.0.3, 3.0.0) railties (3.0.3, 3.0.0) rake (0.8.7) rest-client (1.6.1) rspec (2.0.1) rspec-core (2.0.1) rspec-expectations (2.0.1) rspec-mocks (2.0.1) rspec-rails (2.0.1) ruby-openid (2.1.8) ruby-openid-apps-discovery (1.2.0) rubyntlm (0.1.1) selenium-client (1.2.18) selenium-rc (2.2.4) spork (0.8.4) term-ansicolor (1.0.5) thor (0.14.6, 0.14.3) treetop (1.4.9, 1.4.8) tzinfo (0.3.23) warden (1.0.2, 0.10.7) webrat (0.7.2) -
mehstg
I am having the same issue. Any ideas guys?
root@localhost:/var/ruby/testapp# rake db:create --trace
(in /var/ruby/testapp) 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 Mysql2
/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.3/lib/active_record/railties/databases.rake:64:increate_database' /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.3/lib/active_record/railties/databases.rake:33 /usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:incall' /usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:inexecute' /usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:ineach' /usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:inexecute' /usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:597:ininvoke_with_call_chain' /usr/lib/ruby/1.8/monitor.rb:242:insynchronize' /usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:ininvoke_with_call_chain' /usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:583:ininvoke' /usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2051:ininvoke_task' /usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:intop_level' /usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:ineach' /usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:intop_level' /usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:instandard_exception_handling' /usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2023:intop_level' /usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2001:inrun' /usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:instandard_exception_handling' /usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:1998:inrun' /usr/lib/ruby/gems/1.8/gems/rake-0.8.7/bin/rake:31 /usr/bin/rake:19:inload' /usr/bin/rake:19 -
mehstg
Hi guys
I am having the same issue at the moment. I am running Rails 3.0.3
Local Gems:
LOCAL GEMS
abstract (1.0.0) actionmailer (3.0.3) actionpack (3.0.3) activemodel (3.0.3) activerecord (3.0.3) activeresource (3.0.3) activesupport (3.0.3) arel (2.0.6) builder (2.1.2) bundler (1.0.7) columnize (0.3.2) erubis (2.6.6) i18n (0.5.0) linecache (0.43) mail (2.2.13) mime-types (1.16) mysql (2.8.1) mysql2 (0.2.6) polyglot (0.3.1) rack (1.2.1) rack-mount (0.6.13) rack-test (0.5.6) rails (3.0.3) railties (3.0.3) rake (0.8.7) ruby-debug (0.10.4) ruby-debug-base (0.10.4) ruby-debug-ide (0.4.16) sqlite3-ruby (1.3.2) SystemTimer (1.2.1) thor (0.14.6) treetop (1.4.9) tzinfo (0.3.23)Database config:
development: adapter: mysql2 encoding: utf8 database: testapp_development pool: 5 username: root password: tax1Rank socket: /tmp/mysql.sock
Warning: The database defined as "test" will be erased andre-generated from your development database when you run "rake".
Do not set this db to the same as development or production.
test: adapter: mysql2 encoding: utf8 database: testapp_test pool: 5 username: root password: tax1Rank socket: /tmp/mysql.sock
production: adapter: mysql2 encoding: utf8 database: testapp_production pool: 5 username: root password: tax1Rank socket: /tmp/mysql.sockRake with trace:
(in /var/ruby/testapp) 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 Mysql2 /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.3/lib/active_record/railties/databases.rake:64:increate_database' /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.3/lib/active_record/railties/databases.rake:33 /usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:incall' /usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:inexecute' /usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:ineach' /usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:inexecute' /usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:597:ininvoke_with_call_chain' /usr/lib/ruby/1.8/monitor.rb:242:insynchronize' /usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:ininvoke_with_call_chain' /usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:583:ininvoke' /usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2051:ininvoke_task' /usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:intop_level' /usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:ineach' /usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:intop_level' /usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:instandard_exception_handling' /usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2023:intop_level' /usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2001:inrun' /usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:instandard_exception_handling' /usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:1998:inrun' /usr/lib/ruby/gems/1.8/gems/rake-0.8.7/bin/rake:31 /usr/bin/rake:19:inload' /usr/bin/rake:19</code> </pre> -
Marjan Krekoten'
This patch should help.
-
Goksel
- Assigned user cleared.
It seems like a Mysql Version Problem. Try uninstalling MYSQL 5.5 if you have this version and install MYSQL 5.1
-
Goksel
You can see my blog post, may be it helps : http://geryit.com/blog/2011/01/installing-mysql-with-rails-on-mac-o...
