This project is archived and is in readonly mode.
User mysql2 taked uninitialized constant Mysql error.
Reported by huacnlee (at gmail) | August 24th, 2010 @ 07:46 AM | in 3.0.2
hsli@hs-li:~/work/homeland$ rake db:create --trace
(in /home/hsli/work/homeland) 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
/home/hsli/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.0.rc2/lib/active_record/railties/databases.rake:68:in
rescue in rescue in create_database'
/home/hsli/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.0.rc2/lib/active_record/railties/databases.rake:64:in
rescue
in create_database'
/home/hsli/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.0.rc2/lib/active_record/railties/databases.rake:39:in
create_database'
/home/hsli/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.0.rc2/lib/active_record/railties/databases.rake:33:in
block
(2 levels) in '
/home/hsli/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.8.7/lib/rake.rb:636:in
call'
/home/hsli/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.8.7/lib/rake.rb:636:in
block
in execute'
/home/hsli/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.8.7/lib/rake.rb:631:in
each'
/home/hsli/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.8.7/lib/rake.rb:631:in
execute'
/home/hsli/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.8.7/lib/rake.rb:597:in
block in invoke_with_call_chain'
/home/hsli/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/monitor.rb:201:in
mon_synchronize'
/home/hsli/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.8.7/lib/rake.rb:590:in
invoke_with_call_chain'
/home/hsli/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.8.7/lib/rake.rb:583:in
invoke'
/home/hsli/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.8.7/lib/rake.rb:2051:in
invoke_task'
/home/hsli/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.8.7/lib/rake.rb:2029:in
block
(2 levels) in top_level'
/home/hsli/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.8.7/lib/rake.rb:2029:in
each'
/home/hsli/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.8.7/lib/rake.rb:2029:in
block
in top_level'
/home/hsli/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.8.7/lib/rake.rb:2068:in
standard_exception_handling'
/home/hsli/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.8.7/lib/rake.rb:2023:in
top_level'
/home/hsli/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.8.7/lib/rake.rb:2001:in
block in run'
/home/hsli/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.8.7/lib/rake.rb:2068:in
standard_exception_handling'
/home/hsli/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.8.7/lib/rake.rb:1998:in
run'
/home/hsli/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.8.7/bin/rake:31:in
'
/home/hsli/.rvm/gems/ruby-1.9.2-p0/bin/rake:19:in load'
/home/hsli/.rvm/gems/ruby-1.9.2-p0/bin/rake:19:in
'
I was checked the
/home/hsli/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.0.rc2/lib/active_record/railties/databases.rake
file line 68, is use Mysql::Error trouble is here, I've try add gem
"mysql" into Gemfile, the error was not happen.
new result show me database config was not correct.
Comments and changes to this ticket
-
huacnlee (at gmail) August 24th, 2010 @ 08:10 AM
This is Rails3 Rc2 my database.yml:
development:
adapter: mysql encoding: utf8 reconnect: false database: homeland_development pool: 5 username: monster password: 123123 host: 172.28.150.23 -
huacnlee (at gmail) August 24th, 2010 @ 08:12 AM
last is wrong, I use mysql2 not mysql
development:
adapter: mysql2
encoding: utf8
reconnect: false
database: homeland_development
pool: 5
username: monster
password: 123123
host: 172.28.150.23 -
Andrew White August 24th, 2010 @ 08:39 AM
- Importance changed from to Low
You need to have mysql2 in your Gemfile not mysql - works fine for me in a new app.
-
huacnlee (at gmail) August 24th, 2010 @ 08:46 AM
I was installed mysql2! and I found the resolvtion.
when I change database.yml to:
development:
adapter: mysql2 encoding: utf8 reconnect: false database: "homeland_development" pool: 5 username: "monster" password: "123123" host: "172.28.150.23"add quotes to string value, but why?
-
Andrew White August 24th, 2010 @ 12:49 PM
- Milestone cleared.
- State changed from new to open
- Assigned user set to Andrew White
- Importance changed from Low to High
The problem is that YAML is treating your password as a integer and the Mysql2 library generates an exception when passed a Fixnum for the password. The db:create task assumes that mysql is available and tries to rescue the error but the error class is Mysql2::Error not Mysql::Error so you get the undefined constant error.
The attached patch fixes the db:create task and I've raised an issue on http://github.com/brianmario/mysql2
-
Repository August 25th, 2010 @ 05:18 PM
- State changed from open to resolved
(from [241dfa3c90838957d85022e81d777247e451d832]) Catch mysql2 access denied errors in rake db:create [#5432 state:resolved]
Signed-off-by: Xavier Noria fxn@hashref.com
http://github.com/rails/rails/commit/241dfa3c90838957d85022e81d7772... -
Repository August 25th, 2010 @ 05:18 PM
(from [1fbb0684d267ca61e9409206c9939d0aeab609c9]) Catch mysql2 access denied errors in rake db:create [#5432 state:resolved]
Signed-off-by: Xavier Noria fxn@hashref.com
http://github.com/rails/rails/commit/1fbb0684d267ca61e9409206c9939d... -
The_Lord August 25th, 2010 @ 07:40 PM
It certainly works with database adapter set to mysql2, but still fails when using em_mysql2 (also provided with the mysql2 gem).
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>
People watching this ticket
Attachments
Referenced by
- 5432 User mysql2 taked uninitialized constant Mysql error. (from [241dfa3c90838957d85022e81d777247e451d832]) Catch m...
- 5432 User mysql2 taked uninitialized constant Mysql error. (from [1fbb0684d267ca61e9409206c9939d0aeab609c9]) Catch m...