Topic: (Solved) Password works for 'development', not for 'test' database
My 'development', 'test', and 'production' databases have all the same username and password configured in database.yml, but "rake db:create" works for 'development', but complains (and then fails) passwords for 'test'. How come, since with the same password and username it created the 'development' one? I can login with mysql -u blog -p from the machine hosting the rails app.
database.yml
development:
adapter: mysql2
encoding: utf8
reconnect: false
database: blog_development
pool: 5
username: blog
password: 1234
host: localhost
test:
adapter: mysql2
encoding: utf8
reconnect: false
database: blog_test
pool: 5
username: blog
password: 1234
host: localhost
production:
adapter: mysql2
encoding: utf8
reconnect: false
database: blog_production
pool: 5
username: blog
password: blog123
host: localhostAnd here's the error message:
-bash-4.1, webdev@webdev, Sun Dec 09 08:43:59
$PWD="~/ror/blog/"
$ rake db:create
blog_development already exists
rake aborted!
Mysql2::Error: Access denied for user 'blog'@'localhost' to database 'blog_test': CREATE DATABASE `blog_test` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`
/home/webdev/.rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:245:in `query'
/home/webdev/.rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:245:in `block in execute'
/home/webdev/.rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract_adapter.rb:280:in `block in log'
/home/webdev/.rvm/gems/ruby-1.9.3-p327/gems/activesupport-3.2.9/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/home/webdev/.rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract_adapter.rb:275:in `log'
/home/webdev/.rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:245:in `execute'
/home/webdev/.rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/connection_adapters/mysql2_adapter.rb:211:in `execute'
/home/webdev/.rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:350:in `create_database'
/home/webdev/.rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/railties/databases.rake:106:in `rescue in create_database'
/home/webdev/.rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/railties/databases.rake:74:in `create_database'
/home/webdev/.rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/railties/databases.rake:62:in `block (3 levels) in <top (required)>'
/home/webdev/.rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/railties/databases.rake:62:in `each'
/home/webdev/.rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/railties/databases.rake:62:in `block (2 levels) in <top (required)>'
/home/webdev/.rvm/gems/ruby-1.9.3-p327/bin/ruby_noexec_wrapper:14:in `eval'
/home/webdev/.rvm/gems/ruby-1.9.3-p327/bin/ruby_noexec_wrapper:14:in `<main>'
Tasks: TOP => db:create
(See full trace by running task with --trace)
================================================================================================
-bash-4.1, webdev@webdev, Sun Dec 09 08:48:43
$PWD="~/ror/blog/"
$ mysql -u blog -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 46
Server version: 5.1.66-0+squeeze1 (Debian)
Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> SHOW DATABASES;
+--------------------+
| Database |
+--------------------+
| information_schema |
| blog_development |
+--------------------+
2 rows in set (0.00 sec)
mysql> Bye
================================================================================================
-bash-4.1, webdev@webdev, Sun Dec 09 08:54:59
$PWD="~/ror/blog/"
$Last edited by FernandoBasso (2012-12-09 08:48:47)