I'm very new to rails and am trying to familiarize myself with the framework by following the Rails Essential Training on Lynda.com. Although I thought that I got everything installed properly, I am running into some trouble when trying to launch a WEBrick server. The problem seems to be with mySQL, because I get an error right after it exits on me and I have no idea what it's trying to tell me. If someone could have a look at the error and recommend any possible solutions it would be very much appreciated!!
I am running:
OSX Mountain Lion
Ruby 2.0
Rails 3.2.13
mysql Ver 14.14 Distrib 5.6.10, for osx10.8
adamcord$ rails s
=> Booting WEBrick
=> Rails 3.2.13 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
/Library/Ruby/Gems/1.8/gems/mysql2-0.3.11/lib/mysql2/client.rb:44:in `connect': Unknown database 'simple_cms_development' (Mysql2::Error)
from /Library/Ruby/Gems/1.8/gems/mysql2-0.3.11/lib/mysql2/client.rb:44:in `initialize'
from /Library/Ruby/Gems/1.8/gems/activerecord-3.2.13/lib/active_record/connection_adapters/mysql2_adapter.rb:16:in `new'
from /Library/Ruby/Gems/1.8/gems/activerecord-3.2.13/lib/active_record/connection_adapters/mysql2_adapter.rb:16:in `mysql2_connection'
from /Library/Ruby/Gems/1.8/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:315:in `send'
from /Library/Ruby/Gems/1.8/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:315:in `new_connection'
from /Library/Ruby/Gems/1.8/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:325:in `checkout_new_connection'
from /Library/Ruby/Gems/1.8/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:247:in `checkout'
from /Library/Ruby/Gems/1.8/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:242:in `loop'
from /Library/Ruby/Gems/1.8/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:242:in `checkout'
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
from /Library/Ruby/Gems/1.8/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:239:in `checkout'
from /Library/Ruby/Gems/1.8/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:102:in `connection'
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
from /Library/Ruby/Gems/1.8/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:101:in `connection'
from /Library/Ruby/Gems/1.8/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:410:in `retrieve_connection'
from /Library/Ruby/Gems/1.8/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_specification.rb:171:in `retrieve_connection'
from /Library/Ruby/Gems/1.8/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_specification.rb:145:in `connection'
from /Library/Ruby/Gems/1.8/gems/activerecord-3.2.13/lib/active_record/railtie.rb:88
from /Library/Ruby/Gems/1.8/gems/railties-3.2.13/lib/rails/initializable.rb:30:in `instance_exec'
from /Library/Ruby/Gems/1.8/gems/railties-3.2.13/lib/rails/initializable.rb:30:in `run'
from /Library/Ruby/Gems/1.8/gems/railties-3.2.13/lib/rails/initializable.rb:55:in `run_initializers'
from /Library/Ruby/Gems/1.8/gems/railties-3.2.13/lib/rails/initializable.rb:54:in `each'
from /Library/Ruby/Gems/1.8/gems/railties-3.2.13/lib/rails/initializable.rb:54:in `run_initializers'
from /Library/Ruby/Gems/1.8/gems/railties-3.2.13/lib/rails/application.rb:136:in `initialize!'
from /Library/Ruby/Gems/1.8/gems/railties-3.2.13/lib/rails/railtie/configurable.rb:30:in `send'
from /Library/Ruby/Gems/1.8/gems/railties-3.2.13/lib/rails/railtie/configurable.rb:30:in `method_missing'
from /Users/adamcord/Desktop/Course Work/Lynda.com Exercises/Sites/simple_cms/config/environment.rb:5
from /Users/adamcord/Desktop/Course Work/Lynda.com Exercises/Sites/simple_cms/config.ru:3:in `require'
from /Users/adamcord/Desktop/Course Work/Lynda.com Exercises/Sites/simple_cms/config.ru:3
from /Library/Ruby/Gems/1.8/gems/rack-1.4.5/lib/rack/builder.rb:51:in `instance_eval'
from /Library/Ruby/Gems/1.8/gems/rack-1.4.5/lib/rack/builder.rb:51:in `initialize'
from /Users/adamcord/Desktop/Course Work/Lynda.com Exercises/Sites/simple_cms/config.ru:0:in `new'
from /Users/adamcord/Desktop/Course Work/Lynda.com Exercises/Sites/simple_cms/config.ru:0
I have tried using the rake db:create command but that seems to open up a whole new bag of issues.
The database you are trying to connect to doesn't exist:
Unknown database 'simple_cms_development'
Can you check if it in fact exists and if your settings in config/database.yml are correct ? That may be also the reason why rake db:create also fails (would be useful to paste the errors that you get from it).
Related
I hope this question is not redundant. I saw a question almost like it but as the problem was a bit different it was no help.
I'm trying to connect my ruby rails Application to my MySQL database when using sudo rake db:migrate however (and some other commands) I get the following output
The error says I have a password set but so far as I can tell I do not. I have taken every measure I can think of to ensure that there is none set.
rake aborted!
Mysql::Error: Access denied for user 'root'#'localhost' (using password: YES)
/var/lib/gems/1.9.1/gems/activerecord-4.2.2/lib/active_record/connection_adapters/mysql_adapter.rb:456:in `real_connect'
/var/lib/gems/1.9.1/gems/activerecord-4.2.2/lib/active_record/connection_adapters/mysql_adapter.rb:456:in `connect'
/var/lib/gems/1.9.1/gems/activerecord-4.2.2/lib/active_record/connection_adapters/mysql_adapter.rb:108:in `initialize'
/var/lib/gems/1.9.1/gems/activerecord-4.2.2/lib/active_record/connection_adapters/mysql_adapter.rb:36:in `new'
/var/lib/gems/1.9.1/gems/activerecord-4.2.2/lib/active_record/connection_adapters/mysql_adapter.rb:36:in `mysql_connection'
/var/lib/gems/1.9.1/gems/activerecord-4.2.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:438:in `new_connection'
/var/lib/gems/1.9.1/gems/activerecord-4.2.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:448:in `checkout_new_connection'
/var/lib/gems/1.9.1/gems/activerecord-4.2.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:422:in `acquire_connection'
/var/lib/gems/1.9.1/gems/activerecord-4.2.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:349:in `block in checkout'
/var/lib/gems/1.9.1/gems/activerecord-4.2.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:348:in `checkout'
/var/lib/gems/1.9.1/gems/activerecord-4.2.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:263:in `block in connection'
/var/lib/gems/1.9.1/gems/activerecord-4.2.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:262:in `connection'
/var/lib/gems/1.9.1/gems/activerecord-4.2.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:567:in `retrieve_connection'
/var/lib/gems/1.9.1/gems/activerecord-4.2.2/lib/active_record/connection_handling.rb:113:in `retrieve_connection'
/var/lib/gems/1.9.1/gems/activerecord-4.2.2/lib/active_record/connection_handling.rb:87:in `connection'
/var/lib/gems/1.9.1/gems/activerecord-4.2.2/lib/active_record/migration.rb:913:in `initialize'
/var/lib/gems/1.9.1/gems/activerecord-4.2.2/lib/active_record/migration.rb:820:in `new'
/var/lib/gems/1.9.1/gems/activerecord-4.2.2/lib/active_record/migration.rb:820:in `up'
/var/lib/gems/1.9.1/gems/activerecord-4.2.2/lib/active_record/migration.rb:798:in `migrate'
/var/lib/gems/1.9.1/gems/activerecord-4.2.2/lib/active_record/tasks/database_tasks.rb:137:in `migrate'
/var/lib/gems/1.9.1/gems/activerecord-4.2.2/lib/active_record/railties/databases.rake:44:in `block (2 levels) in <top (required)>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
I'm still fairly new to this so if there is any pertinent information I have not provided please let me know.
Any help would be vary much appreciated.
The (using password: YES) portion of the error error indicates that you sent a password to authenticate, not that one is set. Remove the password: whatever line from your database.yml, if you do not have one set on the database.
I am having an issue connecting to the mysql database using rails. I'm a newbie to rails but I have tried the guide here:
rails + MySQL on OSX: Library not loaded: libmysqlclient.18.dylib
and this still does not work. I believe I have two installations of mysql installed and this is confusing rails.
I have MAMP installed with it's own mysql and I also have the rails mysql2 gem installed. When I follow the steps from the link provided above, I think this is using the MAMP mysql install instead of the mysql2 install that I have with rails gems so it isn't recognizing it.
Is there any way I can consolidate the two mysql's into one? Or is it easier to modify rails so it can see the mysql2 gem?
Here is my error:
~/Sites/RoR3-Essentials/simple_cms ->rails s
=> Booting WEBrick
=> Rails 3.2.13 application starting in development on http://localhost:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
/Users/markmilly/.rvm/gems/ruby-2.0.0-p0/gems/mysql2-0.3.11/lib/mysql2/client.rb:44:in
`connect': Unknown database 'simple_cms_development' (Mysql2::Error)
from /Users/markmilly/.rvm/gems/ruby-2.0.0-p0/gems/mysql2-0.3.11/lib/mysql2/client.rb:44:in `initialize'
from /Users/markmilly/.rvm/gems/ruby-2.0.0-p0/gems/activerecord-3.2.13/lib/active_record/connection_adapters/mysql2_adapter.rb:16:in `new'
from /Users/markmilly/.rvm/gems/ruby-2.0.0-p0/gems/activerecord-3.2.13/lib/active_record/connection_adapters/mysql2_adapter.rb:16:in `mysql2_connection'
from /Users/markmilly/.rvm/gems/ruby-2.0.0-p0/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:315:in `new_connection'
from /Users/markmilly/.rvm/gems/ruby-2.0.0-p0/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:325:in `checkout_new_connection'
from /Users/markmilly/.rvm/gems/ruby-2.0.0-p0/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:247:in `block (2 levels) in checkout'
from /Users/markmilly/.rvm/gems/ruby-2.0.0-p0/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:242:in `loop'
from /Users/markmilly/.rvm/gems/ruby-2.0.0-p0/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:242:in `block in checkout'
from /Users/markmilly/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
from /Users/markmilly/.rvm/gems/ruby-2.0.0-p0/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:239:in `checkout'
from /Users/markmilly/.rvm/gems/ruby-2.0.0-p0/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:102:in `block in connection'
from /Users/markmilly/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
from /Users/markmilly/.rvm/gems/ruby-2.0.0-p0/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:101:in `connection'
from /Users/markmilly/.rvm/gems/ruby-2.0.0-p0/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:410:in `retrieve_connection'
from /Users/markmilly/.rvm/gems/ruby-2.0.0-p0/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_specification.rb:171:in `retrieve_connection'
from /Users/markmilly/.rvm/gems/ruby-2.0.0-p0/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_specification.rb:145:in `connection'
from /Users/markmilly/.rvm/gems/ruby-2.0.0-p0/gems/activerecord-3.2.13/lib/active_record/railtie.rb:88:in `block in <class:Railtie>'
from /Users/markmilly/.rvm/gems/ruby-2.0.0-p0/gems/railties-3.2.13/lib/rails/initializable.rb:30:in `instance_exec'
from /Users/markmilly/.rvm/gems/ruby-2.0.0-p0/gems/railties-3.2.13/lib/rails/initializable.rb:30:in `run'
from /Users/markmilly/.rvm/gems/ruby-2.0.0-p0/gems/railties-3.2.13/lib/rails/initializable.rb:55:in `block in run_initializers'
from /Users/markmilly/.rvm/gems/ruby-2.0.0-p0/gems/railties-3.2.13/lib/rails/initializable.rb:54:in `each'
from /Users/markmilly/.rvm/gems/ruby-2.0.0-p0/gems/railties-3.2.13/lib/rails/initializable.rb:54:in `run_initializers'
from /Users/markmilly/.rvm/gems/ruby-2.0.0-p0/gems/railties-3.2.13/lib/rails/application.rb:136:in `initialize!'
from /Users/markmilly/.rvm/gems/ruby-2.0.0-p0/gems/railties-3.2.13/lib/rails/railtie/configurable.rb:30:in `method_missing'
from /Users/markmilly/Sites/RoR3-Essentials/simple_cms/config/environment.rb:5:in `<top (required)>'
from /Users/markmilly/Sites/RoR3-Essentials/simple_cms/config.ru:3:in `require'
from /Users/markmilly/Sites/RoR3-Essentials/simple_cms/config.ru:3:in `block in <main>'
from /Users/markmilly/.rvm/gems/ruby-2.0.0-p0/gems/rack-1.4.5/lib/rack/builder.rb:51:in `instance_eval'
from /Users/markmilly/.rvm/gems/ruby-2.0.0-p0/gems/rack-1.4.5/lib/rack/builder.rb:51:in `initialize'
from /Users/markmilly/Sites/RoR3-Essentials/simple_cms/config.ru:in `new'
from /Users/markmilly/Sites/RoR3-Essentials/simple_cms/config.ru:in `<main>'
from /Users/markmilly/.rvm/gems/ruby-2.0.0-p0/gems/rack-1.4.5/lib/rack/builder.rb:40:in `eval'
from /Users/markmilly/.rvm/gems/ruby-2.0.0-p0/gems/rack-1.4.5/lib/rack/builder.rb:40:in `parse_file'
from /Users/markmilly/.rvm/gems/ruby-2.0.0-p0/gems/rack-1.4.5/lib/rack/server.rb:200:in `app'
from /Users/markmilly/.rvm/gems/ruby-2.0.0-p0/gems/railties-3.2.13/lib/rails/commands/server.rb:46:in `app'
from /Users/markmilly/.rvm/gems/ruby-2.0.0-p0/gems/rack-1.4.5/lib/rack/server.rb:304:in `wrapped_app'
from /Users/markmilly/.rvm/gems/ruby-2.0.0-p0/gems/rack-1.4.5/lib/rack/server.rb:254:in `start'
from /Users/markmilly/.rvm/gems/ruby-2.0.0-p0/gems/railties-3.2.13/lib/rails/commands/server.rb:70:in `start'
from /Users/markmilly/.rvm/gems/ruby-2.0.0-p0/gems/railties-3.2.13/lib/rails/commands.rb:55:in `block in <top (required)>'
from /Users/markmilly/.rvm/gems/ruby-2.0.0-p0/gems/railties-3.2.13/lib/rails/commands.rb:50:in `tap'
from /Users/markmilly/.rvm/gems/ruby-2.0.0-p0/gems/railties-3.2.13/lib/rails/commands.rb:50:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
#markmilly Answer to your last comment:
'rake db:create' creates the db that you specified in your config/database.yml file.
It will create the db for the current RAILS_ENV you're on. If the environment is not specified it will default to the development and test db's.
I see this answer is a bit late, but it might help someone else.
I'm currently stuck on what is (I hope a newby) problem with a rails project (this is my first rails project and so I apologise if I miss anything crucial). I've been at this for a couple of hours and can't seem to find any solutions. I have tried the solutions to the following threads with no avail.
connect to local MySQL server through socket
Can't connect to local MySQL server through socket
Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
Can't connect to local MySQL server through socket '/tmp/mysql.sock'
The list goes on, anyway some of the threads are similar to my situation others are just clutching at straws. Let me give you a quick overview of my situation.
The project has been developed on a mac
I have recently set up a test server as a means of learning the deployment process
The server is running Ubuntu Server 12.04
I managed to follow some tutorials to set it up including the Capistrano deployment tutorial up to the point of:
$ rake RAILS_ENV=production db:schema:load
which was where I first encountered the Can't connect to local MySQL server error.
if I run it with --trace I get the following output:
** Invoke db:schema:load (first_time)
** Invoke environment (first_time)
** Execute environment
rake aborted!
Can't connect to local MySQL server through socket '/var/run/mysqld/mysql.sock' (2)
/usr/share/ruby-rvm/gems/ruby-1.9.2-p318#rails_3_2/gems/mysql2-0.3.11/lib/mysql2/client.rb:44:in `connect'
/usr/share/ruby-rvm/gems/ruby-1.9.2-p318#rails_3_2/gems/mysql2-0.3.11/lib/mysql2/client.rb:44:in `initialize'
/usr/share/ruby-rvm/gems/ruby-1.9.2-p318#rails_3_2/gems/activerecord-3.2.2/lib/active_record/connection_adapters/mysql2_adapter.rb:16:in `new'
/usr/share/ruby-rvm/gems/ruby-1.9.2-p318#rails_3_2/gems/activerecord-3.2.2/lib/active_record/connection_adapters/mysql2_adapter.rb:16:in `mysql2_connection'
/usr/share/ruby-rvm/gems/ruby-1.9.2-p318#rails_3_2/gems/activerecord-3.2.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:277:in `new_connection'
/usr/share/ruby-rvm/gems/ruby-1.9.2-p318#rails_3_2/gems/activerecord-3.2.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:287:in `checkout_new_connection'
/usr/share/ruby-rvm/gems/ruby-1.9.2-p318#rails_3_2/gems/activerecord-3.2.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:235:in `block (2 levels) in checkout'
/usr/share/ruby-rvm/gems/ruby-1.9.2-p318#rails_3_2/gems/activerecord-3.2.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:230:in `loop'
/usr/share/ruby-rvm/gems/ruby-1.9.2-p318#rails_3_2/gems/activerecord-3.2.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:230:in `block in checkout'
/usr/share/ruby-rvm/rubies/ruby-1.9.2-p318/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/usr/share/ruby-rvm/gems/ruby-1.9.2-p318#rails_3_2/gems/activerecord-3.2.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:229:in `checkout'
/usr/share/ruby-rvm/gems/ruby-1.9.2-p318#rails_3_2/gems/activerecord-3.2.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:95:in `connection'
/usr/share/ruby-rvm/gems/ruby-1.9.2-p318#rails_3_2/gems/activerecord-3.2.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:374:in `retrieve_connection'
/usr/share/ruby-rvm/gems/ruby-1.9.2-p318#rails_3_2/gems/activerecord-3.2.2/lib/active_record/connection_adapters/abstract/connection_specification.rb:168:in `retrieve_connection'
/usr/share/ruby-rvm/gems/ruby-1.9.2-p318#rails_3_2/gems/activerecord-3.2.2/lib/active_record/connection_adapters/abstract/connection_specification.rb:142:in `connection'
/usr/share/ruby-rvm/gems/ruby-1.9.2-p318#rails_3_2/gems/activerecord-3.2.2/lib/active_record/model_schema.rb:308:in `clear_cache!'
/usr/share/ruby-rvm/gems/ruby-1.9.2-p318#rails_3_2/gems/activerecord-3.2.2/lib/active_record/railtie.rb:91:in `block (2 levels) in <class:Railtie>'
/usr/share/ruby-rvm/gems/ruby-1.9.2-p318#rails_3_2/gems/activesupport-3.2.2/lib/active_support/callbacks.rb:418:in `_run__427268845__prepare__407057367__callbacks'
/usr/share/ruby-rvm/gems/ruby-1.9.2-p318#rails_3_2/gems/activesupport-3.2.2/lib/active_support/callbacks.rb:405:in `__run_callback'
/usr/share/ruby-rvm/gems/ruby-1.9.2-p318#rails_3_2/gems/activesupport-3.2.2/lib/active_support/callbacks.rb:385:in `_run_prepare_callbacks'
/usr/share/ruby-rvm/gems/ruby-1.9.2-p318#rails_3_2/gems/activesupport-3.2.2/lib/active_support/callbacks.rb:81:in `run_callbacks'
/usr/share/ruby-rvm/gems/ruby-1.9.2-p318#rails_3_2/gems/actionpack-3.2.2/lib/action_dispatch/middleware/reloader.rb:74:in `prepare!'
/usr/share/ruby-rvm/gems/ruby-1.9.2-p318#rails_3_2/gems/actionpack-3.2.2/lib/action_dispatch/middleware/reloader.rb:48:in `prepare!'
/usr/share/ruby-rvm/gems/ruby-1.9.2-p318#rails_3_2/gems/railties-3.2.2/lib/rails/application/finisher.rb:47:in `block in <module:Finisher>'
/usr/share/ruby-rvm/gems/ruby-1.9.2-p318#rails_3_2/gems/railties-3.2.2/lib/rails/initializable.rb:30:in `instance_exec'
/usr/share/ruby-rvm/gems/ruby-1.9.2-p318#rails_3_2/gems/railties-3.2.2/lib/rails/initializable.rb:30:in `run'
/usr/share/ruby-rvm/gems/ruby-1.9.2-p318#rails_3_2/gems/railties-3.2.2/lib/rails/initializable.rb:55:in `block in run_initializers'
/usr/share/ruby-rvm/gems/ruby-1.9.2-p318#rails_3_2/gems/railties-3.2.2/lib/rails/initializable.rb:54:in `each'
/usr/share/ruby-rvm/gems/ruby-1.9.2-p318#rails_3_2/gems/railties-3.2.2/lib/rails/initializable.rb:54:in `run_initializers'
/usr/share/ruby-rvm/gems/ruby-1.9.2-p318#rails_3_2/gems/railties-3.2.2/lib/rails/application.rb:136:in `initialize!'
/usr/share/ruby-rvm/gems/ruby-1.9.2-p318#rails_3_2/gems/railties-3.2.2/lib/rails/railtie/configurable.rb:30:in `method_missing'
/var/www/little_oven_deploy/releases/20120705162026/config/environment.rb:5:in `<top (required)>'
/usr/share/ruby-rvm/gems/ruby-1.9.2-p318#rails_3_2/gems/activesupport-3.2.2/lib/active_support/dependencies.rb:251:in `require'
/usr/share/ruby-rvm/gems/ruby-1.9.2-p318#rails_3_2/gems/activesupport-3.2.2/lib/active_support/dependencies.rb:251:in `block in require'
/usr/share/ruby-rvm/gems/ruby-1.9.2-p318#rails_3_2/gems/activesupport-3.2.2/lib/active_support/dependencies.rb:236:in `load_dependency'
/usr/share/ruby-rvm/gems/ruby-1.9.2-p318#rails_3_2/gems/activesupport-3.2.2/lib/active_support/dependencies.rb:251:in `require'
/usr/share/ruby-rvm/gems/ruby-1.9.2-p318#rails_3_2/gems/railties-3.2.2/lib/rails/application.rb:103:in `require_environment!'
/usr/share/ruby-rvm/gems/ruby-1.9.2-p318#rails_3_2/gems/railties-3.2.2/lib/rails/application.rb:292:in `block (2 levels) in initialize_tasks'
/usr/share/ruby-rvm/gems/ruby-1.9.2-p318#global/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `call'
/usr/share/ruby-rvm/gems/ruby-1.9.2-p318#global/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `block in execute'
/usr/share/ruby-rvm/gems/ruby-1.9.2-p318#global/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `each'
/usr/share/ruby-rvm/gems/ruby-1.9.2-p318#global/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute'
/usr/share/ruby-rvm/gems/ruby-1.9.2-p318#global/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain'
/usr/share/ruby-rvm/rubies/ruby-1.9.2-p318/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/usr/share/ruby-rvm/gems/ruby-1.9.2-p318#global/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/usr/share/ruby-rvm/gems/ruby-1.9.2-p318#global/gems/rake-0.9.2.2/lib/rake/task.rb:176:in `block in invoke_prerequisites'
/usr/share/ruby-rvm/gems/ruby-1.9.2-p318#global/gems/rake-0.9.2.2/lib/rake/task.rb:174:in `each'
/usr/share/ruby-rvm/gems/ruby-1.9.2-p318#global/gems/rake-0.9.2.2/lib/rake/task.rb:174:in `invoke_prerequisites'
/usr/share/ruby-rvm/gems/ruby-1.9.2-p318#global/gems/rake-0.9.2.2/lib/rake/task.rb:157:in `block in invoke_with_call_chain'
/usr/share/ruby-rvm/rubies/ruby-1.9.2-p318/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/usr/share/ruby-rvm/gems/ruby-1.9.2-p318#global/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/usr/share/ruby-rvm/gems/ruby-1.9.2-p318#global/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke'
/usr/share/ruby-rvm/gems/ruby-1.9.2-p318#global/gems/rake-0.9.2.2/lib/rake/application.rb:116:in `invoke_task'
/usr/share/ruby-rvm/gems/ruby-1.9.2-p318#global/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block (2 levels) in top_level'
/usr/share/ruby-rvm/gems/ruby-1.9.2-p318#global/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `each'
/usr/share/ruby-rvm/gems/ruby-1.9.2-p318#global/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block in top_level'
/usr/share/ruby-rvm/gems/ruby-1.9.2-p318#global/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/usr/share/ruby-rvm/gems/ruby-1.9.2-p318#global/gems/rake-0.9.2.2/lib/rake/application.rb:88:in `top_level'
/usr/share/ruby-rvm/gems/ruby-1.9.2-p318#global/gems/rake-0.9.2.2/lib/rake/application.rb:66:in `block in run'
/usr/share/ruby-rvm/gems/ruby-1.9.2-p318#global/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/usr/share/ruby-rvm/gems/ruby-1.9.2-p318#global/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
/usr/share/ruby-rvm/gems/ruby-1.9.2-p318#global/gems/rake-0.9.2.2/bin/rake:33:in `<top (required)>'
/usr/share/ruby-rvm/gems/ruby-1.9.2-p318#global/bin/rake:19:in `load'
/usr/share/ruby-rvm/gems/ruby-1.9.2-p318#global/bin/rake:19:in `<main>'
/usr/share/ruby-rvm/gems/ruby-1.9.2-p318#rails_3_2/bin/ruby_noexec_wrapper:14:in `eval'
/usr/share/ruby-rvm/gems/ruby-1.9.2-p318#rails_3_2/bin/ruby_noexec_wrapper:14:in `<main>'
Tasks: TOP => db:schema:load => environment
my database.yml file is as follows:
# MySQL. Versions 4.1 and 5.0 are recommended.
#
# Install the MYSQL driver
# gem install mysql2
#
# Ensure the MySQL gem is defined in your Gemfile
# gem 'mysql2'
#
# And be sure to use new-style password hashing:
# http://dev.mysql.com/doc/refman/5.0/en/old-client.html
development:
adapter: mysql2
encoding: utf8
reconnect: false
database: little_oven_devel
pool: 5
username: devel
password: Development1
socket: /var/run/mysqld/mysql.sock
# Warning: The database defined as "test" will be erased and
# re-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
reconnect: false
database: little_oven_test
pool: 5
username: root
password:
socket: /tmp/mysql.sock
production:
adapter: mysql2
encoding: utf8
reconnect: false
database: little_oven_production
pool: 5
username: production
password: Production1
socket: /var/run/mysqld/mysql.sock
Note that I have changed the location of the socket variable to correspond with what I believe is the .sock file on ubuntu as this differs from a standard install on mac OSX.
finally, I also get the same error when running
rails c
with the following output:
/usr/share/ruby-rvm/gems/ruby-1.9.2-p318#rails_3_2/gems/mysql2-0.3.11/lib/mysql2/client.rb:44:in `connect': Can't connect to local MySQL server through socket '/var/run/mysqld/mysql.sock' (2) (Mysql2::Error)
from /usr/share/ruby-rvm/gems/ruby-1.9.2-p318#rails_3_2/gems/mysql2-0.3.11/lib/mysql2/client.rb:44:in `initialize'
from /usr/share/ruby-rvm/gems/ruby-1.9.2-p318#rails_3_2/gems/activerecord-3.2.2/lib/active_record/connection_adapters/mysql2_adapter.rb:16:in `new'
from /usr/share/ruby-rvm/gems/ruby-1.9.2-p318#rails_3_2/gems/activerecord-3.2.2/lib/active_record/connection_adapters/mysql2_adapter.rb:16:in `mysql2_connection'
from /usr/share/ruby-rvm/gems/ruby-1.9.2-p318#rails_3_2/gems/activerecord-3.2.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:277:in `new_connection'
from /usr/share/ruby-rvm/gems/ruby-1.9.2-p318#rails_3_2/gems/activerecord-3.2.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:287:in `checkout_new_connection'
from /usr/share/ruby-rvm/gems/ruby-1.9.2-p318#rails_3_2/gems/activerecord-3.2.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:235:in `block (2 levels) in checkout'
from /usr/share/ruby-rvm/gems/ruby-1.9.2-p318#rails_3_2/gems/activerecord-3.2.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:230:in `loop'
from /usr/share/ruby-rvm/gems/ruby-1.9.2-p318#rails_3_2/gems/activerecord-3.2.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:230:in `block in checkout'
from /usr/share/ruby-rvm/rubies/ruby-1.9.2-p318/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
from /usr/share/ruby-rvm/gems/ruby-1.9.2-p318#rails_3_2/gems/activerecord-3.2.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:229:in `checkout'
from /usr/share/ruby-rvm/gems/ruby-1.9.2-p318#rails_3_2/gems/activerecord-3.2.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:95:in `connection'
from /usr/share/ruby-rvm/gems/ruby-1.9.2-p318#rails_3_2/gems/activerecord-3.2.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:374:in `retrieve_connection'
from /usr/share/ruby-rvm/gems/ruby-1.9.2-p318#rails_3_2/gems/activerecord-3.2.2/lib/active_record/connection_adapters/abstract/connection_specification.rb:168:in `retrieve_connection'
from /usr/share/ruby-rvm/gems/ruby-1.9.2-p318#rails_3_2/gems/activerecord-3.2.2/lib/active_record/connection_adapters/abstract/connection_specification.rb:142:in `connection'
from /usr/share/ruby-rvm/gems/ruby-1.9.2-p318#rails_3_2/gems/activerecord-3.2.2/lib/active_record/model_schema.rb:308:in `clear_cache!'
from /usr/share/ruby-rvm/gems/ruby-1.9.2-p318#rails_3_2/gems/activerecord-3.2.2/lib/active_record/railtie.rb:91:in `block (2 levels) in <class:Railtie>'
from /usr/share/ruby-rvm/gems/ruby-1.9.2-p318#rails_3_2/gems/activesupport-3.2.2/lib/active_support/callbacks.rb:418:in `_run__485859349__prepare__1069885904__callbacks'
from /usr/share/ruby-rvm/gems/ruby-1.9.2-p318#rails_3_2/gems/activesupport-3.2.2/lib/active_support/callbacks.rb:405:in `__run_callback'
from /usr/share/ruby-rvm/gems/ruby-1.9.2-p318#rails_3_2/gems/activesupport-3.2.2/lib/active_support/callbacks.rb:385:in `_run_prepare_callbacks'
from /usr/share/ruby-rvm/gems/ruby-1.9.2-p318#rails_3_2/gems/activesupport-3.2.2/lib/active_support/callbacks.rb:81:in `run_callbacks'
from /usr/share/ruby-rvm/gems/ruby-1.9.2-p318#rails_3_2/gems/actionpack-3.2.2/lib/action_dispatch/middleware/reloader.rb:74:in `prepare!'
from /usr/share/ruby-rvm/gems/ruby-1.9.2-p318#rails_3_2/gems/actionpack-3.2.2/lib/action_dispatch/middleware/reloader.rb:48:in `prepare!'
from /usr/share/ruby-rvm/gems/ruby-1.9.2-p318#rails_3_2/gems/railties-3.2.2/lib/rails/application/finisher.rb:47:in `block in <module:Finisher>'
from /usr/share/ruby-rvm/gems/ruby-1.9.2-p318#rails_3_2/gems/railties-3.2.2/lib/rails/initializable.rb:30:in `instance_exec'
from /usr/share/ruby-rvm/gems/ruby-1.9.2-p318#rails_3_2/gems/railties-3.2.2/lib/rails/initializable.rb:30:in `run'
from /usr/share/ruby-rvm/gems/ruby-1.9.2-p318#rails_3_2/gems/railties-3.2.2/lib/rails/initializable.rb:55:in `block in run_initializers'
from /usr/share/ruby-rvm/gems/ruby-1.9.2-p318#rails_3_2/gems/railties-3.2.2/lib/rails/initializable.rb:54:in `each'
from /usr/share/ruby-rvm/gems/ruby-1.9.2-p318#rails_3_2/gems/railties-3.2.2/lib/rails/initializable.rb:54:in `run_initializers'
from /usr/share/ruby-rvm/gems/ruby-1.9.2-p318#rails_3_2/gems/railties-3.2.2/lib/rails/application.rb:136:in `initialize!'
from /usr/share/ruby-rvm/gems/ruby-1.9.2-p318#rails_3_2/gems/railties-3.2.2/lib/rails/railtie/configurable.rb:30:in `method_missing'
from /var/www/little_oven_deploy/releases/20120705162026/config/environment.rb:5:in `<top (required)>'
from /usr/share/ruby-rvm/gems/ruby-1.9.2-p318#rails_3_2/gems/activesupport-3.2.2/lib/active_support/dependencies.rb:251:in `require'
from /usr/share/ruby-rvm/gems/ruby-1.9.2-p318#rails_3_2/gems/activesupport-3.2.2/lib/active_support/dependencies.rb:251:in `block in require'
from /usr/share/ruby-rvm/gems/ruby-1.9.2-p318#rails_3_2/gems/activesupport-3.2.2/lib/active_support/dependencies.rb:236:in `load_dependency'
from /usr/share/ruby-rvm/gems/ruby-1.9.2-p318#rails_3_2/gems/activesupport-3.2.2/lib/active_support/dependencies.rb:251:in `require'
from /usr/share/ruby-rvm/gems/ruby-1.9.2-p318#rails_3_2/gems/railties-3.2.2/lib/rails/application.rb:103:in `require_environment!'
from /usr/share/ruby-rvm/gems/ruby-1.9.2-p318#rails_3_2/gems/railties-3.2.2/lib/rails/commands.rb:40:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
I would like to point out that the location /usr/share/ruby-rvm/gems/ruby-1.9.2-p318#rails_3_2/gems/mysql2-0.3.11/lib/mysql2/client.rb is valid. Also, mysql is running and I can access it with:
mysql -u production -p
You can alternatively remove the socket specification from the production environment in database.yml
production:
# socket: /var/run/mysqld/mysql.sock
I understand performance is reduced slightly, but it got me through a similar problem.
/tmp/mysqld.sock is the location of the socket for OSX.
On linux Mint/Ubuntu, it should be at /var/run/mysqld/mysql.sock.
If it's not, then the location should be referenced in one of the MySQL config files, named my.cnf. The location and load order of these files will print out if you enter
mysql --help
into a terminal. If you can't find the my.cnf file at the specified path, it doesn't exist, so ignore it, and look to the next one in the load order.
^ That is the simple, surefire way to verify your socks configuration.
Josh Lewis's answer should be valid, as my Rails 4.0.3 install defaults to omitting the socket line - so I'm assuming it's predefined or auto-configured by the installation, and it's not something you should have to worry about.
Not to revive an old question, but it comes up as a top listing on Google search.
Some random ideas:
Who is the owner of /var/run/mysqld/mysql.sock? I know it's in a first link you mentioned, but maybe you missed it. Is it accessible for user from whom you run commands?
Maybe default MySQL port (3306) is blocked? I suppose it may prevent Rails, even when you're running things locally since in Unix design ports are everywhere. If you're running on Amazon, notice that they keep all ports closed by default (as well as dropping all PING requests by default, but that's another issue) and you may have to click through options in their dashboard
try to add host: 127.0.0.1 and port: 3306 to your production config settings
try to remove pool and reconnect options and see what happens (that's a totally wild guess)
there are some ideas over there, that in such case you should uninstall mysql-client and mysql-server packages and install them again, but I've not seen a point why is that
$ mysqld
f error "mysql-files" dir
$ sudo mkdir /var/lib/mysql-files
$ sudo chown -R mysql:mysql /var/lib/mysql-files/
$ sudo chmod 700 /var/lib/mysql-files/
I am unable to setup my MySQL DB for Ruby on Rails. After setting up the DB and making sure the config/database.yml file match, I am running into the error message below.
U:\Rails\alpha>rake db:migrate --trace
(in U:/Rails/alpha)
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:migrate
rake aborted!
Access denied for user 'admin'#'207-237-91-100.c3-0.avec-ubr13.nyr-avec.n
y.cable.rcn.com' (using password: YES)
C:/Ruby187/lib/ruby/gems/1.8/gems/mysql2-0.2.6-x86-mingw32/lib/mysql2/client.rb:
37:in `connect'
C:/Ruby187/lib/ruby/gems/1.8/gems/mysql2-0.2.6-x86-mingw32/lib/mysql2/client.rb:
37:in `initialize'
C:/Ruby187/lib/ruby/gems/1.8/gems/mysql2-0.2.6-x86-mingw32/lib/active_record/con
nection_adapters/mysql2_adapter.rb:14:in `new'
C:/Ruby187/lib/ruby/gems/1.8/gems/mysql2-0.2.6-x86-mingw32/lib/active_record/con
nection_adapters/mysql2_adapter.rb:14:in `mysql2_connection'
C:/Ruby187/lib/ruby/gems/1.8/gems/activerecord-3.0.1/lib/active_record/connectio
n_adapters/abstract/connection_pool.rb:230:in `send'
C:/Ruby187/lib/ruby/gems/1.8/gems/activerecord-3.0.1/lib/active_record/connectio
n_adapters/abstract/connection_pool.rb:230:in `new_connection'
C:/Ruby187/lib/ruby/gems/1.8/gems/activerecord-3.0.1/lib/active_record/connectio
n_adapters/abstract/connection_pool.rb:238:in `checkout_new_connection'
C:/Ruby187/lib/ruby/gems/1.8/gems/activerecord-3.0.1/lib/active_record/connectio
n_adapters/abstract/connection_pool.rb:194:in `checkout'
C:/Ruby187/lib/ruby/gems/1.8/gems/activerecord-3.0.1/lib/active_record/connectio
n_adapters/abstract/connection_pool.rb:190:in `loop'
C:/Ruby187/lib/ruby/gems/1.8/gems/activerecord-3.0.1/lib/active_record/connectio
n_adapters/abstract/connection_pool.rb:190:in `checkout'
C:/Ruby187/lib/ruby/1.8/monitor.rb:242:in `synchronize'
C:/Ruby187/lib/ruby/gems/1.8/gems/activerecord-3.0.1/lib/active_record/connectio
n_adapters/abstract/connection_pool.rb:189:in `checkout'
C:/Ruby187/lib/ruby/gems/1.8/gems/activerecord-3.0.1/lib/active_record/connectio
n_adapters/abstract/connection_pool.rb:96:in `connection'
C:/Ruby187/lib/ruby/gems/1.8/gems/activerecord-3.0.1/lib/active_record/connectio
n_adapters/abstract/connection_pool.rb:318:in `retrieve_connection'
C:/Ruby187/lib/ruby/gems/1.8/gems/activerecord-3.0.1/lib/active_record/connectio
n_adapters/abstract/connection_specification.rb:97:in `retrieve_connection'
C:/Ruby187/lib/ruby/gems/1.8/gems/activerecord-3.0.1/lib/active_record/connectio
n_adapters/abstract/connection_specification.rb:89:in `connection'
C:/Ruby187/lib/ruby/gems/1.8/gems/activerecord-3.0.1/lib/active_record/migration
.rb:486:in `initialize'
C:/Ruby187/lib/ruby/gems/1.8/gems/activerecord-3.0.1/lib/active_record/migration
.rb:433:in `new'
C:/Ruby187/lib/ruby/gems/1.8/gems/activerecord-3.0.1/lib/active_record/migration
.rb:433:in `up'
C:/Ruby187/lib/ruby/gems/1.8/gems/activerecord-3.0.1/lib/active_record/migration
.rb:415:in `migrate'
C:/Ruby187/lib/ruby/gems/1.8/gems/activerecord-3.0.1/lib/active_record/railties/
databases.rake:142
C:/Ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `call'
C:/Ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `execute'
C:/Ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `each'
C:/Ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `execute'
C:/Ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:597:in `invoke_with_cal
l_chain'
C:/Ruby187/lib/ruby/1.8/monitor.rb:242:in `synchronize'
C:/Ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_cal
l_chain'
C:/Ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:583:in `invoke'
C:/Ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2051:in `invoke_task'
C:/Ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
C:/Ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `each'
C:/Ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
C:/Ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_excep
tion_handling'
C:/Ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2023:in `top_level'
C:/Ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2001:in `run'
C:/Ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_excep
tion_handling'
C:/Ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:1998:in `run'
C:/Ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/bin/rake:31
C:/Ruby187/bin/rake:19:in `load'
C:/Ruby187/bin/rake:19
I've checked the password about 15+ times and it's correct as far as I can tell.
database.yml file:
development:
adapter: mysql2
encoding: utf8
reconnect: false
database: dbname
pool: 5
username: admin
password: pwhere
host: sql.domain.com
Thanks
One way to test this would be to connect to mysql on the command line from the machine where rails lives. Something like
mysql -u admin -ppwhere -h sql.domain.com
You likely will find that you can't connect that way, either. If so, you've probably got a GRANT problem, which is probably due to specifying the wrong host in the GRANT. For example, if the DB and rails reside on the same machine, mysql may think you are connecting from 'localhost', instead of the DNS name of the rails box (or vice versa).
At the outset you may simply want to grant the admin user access to everything:
GRANT ALL ON *.* to 'admin'#'whereever_rails_lives' IDENTIFIED BY 'pwhere'
mysql grant syntax
The trick is often getting 'whereever_rails_lives' right.
You permissions are incorrect. This is such a lame error because it really means two things. 1) you have the wrong password/username combination; also, you cannot connect to mysql which could seriously mean connecting to a gem problem,installation problem. Mysql can get fussy!
From your question, I'm gathering that you're pretty new to all of this. What i would suggest is instead of worry about connecting to MySQL, you start with sqlite. You don't need fulltext search and the other features that lite doesn't provide!
So, let's get started with sqlite3. How?
It's less work. Just make a rails app, and rake db:create and you are done. Then when you need the features of a mysql database you can really know what's going on with the errors in terms of you being familiar with Rails and debugging.
Ok, I'm done.
I can't understand why I got this error with:
rake features
It cant' be I can't connect to mysql cause the:
rake db:migrate
works perfectly.
I keep having this error:
rake features --trace
(in /Users/myname/Projects/rails_app)
** Invoke features (first_time)
** Invoke db:test:prepare (first_time)
** Invoke db:abort_if_pending_migrations (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:abort_if_pending_migrations
** Execute db:test:prepare
** Invoke db:test:load (first_time)
** Invoke db:test:purge (first_time)
** Invoke environment
** Execute db:test:purge
** Execute db:test:load
** Invoke db:schema:load (first_time)
** Invoke environment
** Execute db:schema:load
rake aborted!
closed stream
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/mysql.rb:1032:in `sync='
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/mysql.rb:1032:in `write'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/mysql.rb:1092:in `finalizer'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/mysql.rb:578:in `call'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/mysql.rb:578:in `start'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/mysql.rb:578:in `free'
/Users/myname/Projects/rails_app/vendor/rails/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb:438:in `tables'
/Users/myname/Projects/rails_app/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb:24:in `table_exists?'
/Users/myname/Projects/rails_app/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb:106:in `create_table'
/Users/myname/Projects/rails_app/vendor/rails/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb:473:in `create_table'
/Users/myname/Projects/rails_app/vendor/rails/activerecord/lib/active_record/migration.rb:352:in `send'
/Users/myname/Projects/rails_app/vendor/rails/activerecord/lib/active_record/migration.rb:352:in `method_missing'
/Users/myname/Projects/rails_app/vendor/rails/activerecord/lib/active_record/migration.rb:328:in `say_with_time'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/benchmark.rb:293:in `measure'
/Users/myname/Projects/rails_app/vendor/rails/activerecord/lib/active_record/migration.rb:328:in `say_with_time'
/Users/myname/Projects/rails_app/vendor/rails/activerecord/lib/active_record/migration.rb:348:in `method_missing'
/Users/myname/Projects/rails_app/db/schema.rb:38
/Users/myname/Projects/rails_app/vendor/rails/activerecord/lib/active_record/schema.rb:43:in `instance_eval'
/Users/myname/Projects/rails_app/vendor/rails/activerecord/lib/active_record/schema.rb:43:in `define'
/Users/myname/Projects/rails_app/db/schema.rb:12
/Users/myname/Projects/rails_app/vendor/rails/activesupport/lib/active_support/dependencies.rb:145:in `load_without_new_constant_marking'
/Users/myname/Projects/rails_app/vendor/rails/activesupport/lib/active_support/dependencies.rb:145:in `load'
/Users/myname/Projects/rails_app/vendor/rails/activesupport/lib/active_support/dependencies.rb:521:in `new_constants_in'
/Users/myname/Projects/rails_app/vendor/rails/activesupport/lib/active_support/dependencies.rb:145:in `load'
/Users/myname/Projects/rails_app/vendor/rails/railties/lib/tasks/databases.rake:259
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `call'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `execute'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `each'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `execute'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:597:in `invoke_with_call_chain'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:583:in `invoke'
/Users/myname/Projects/rails_app/vendor/rails/railties/lib/tasks/databases.rake:304
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `call'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `execute'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `each'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `execute'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:597:in `invoke_with_call_chain'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:583:in `invoke'
/Users/myname/Projects/rails_app/vendor/rails/railties/lib/tasks/databases.rake:378
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `call'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `execute'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `each'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `execute'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:597:in `invoke_with_call_chain'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:607:in `invoke_prerequisites'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:604:in `each'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:604:in `invoke_prerequisites'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:596:in `invoke_with_call_chain'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:583:in `invoke'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:2051:in `invoke_task'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `each'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:2023:in `top_level'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:2001:in `run'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:1998:in `run'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/bin/rake:31
/usr/bin/rake:19:in `load'
/usr/bin/rake:19
My machine:
Mac OS X 10.5.8
ruby 1.8.6 (2008-08-11 patchlevel 287) [universal-darwin9.0]
Rails 2.3.4
mysql (2.8.1) [rubygem]
Mysql path: /opt/local/lib/mysql5 [installed via macport]
Thank you so much!
Save your DBs and reinstall mysql. Follow http://hivelogic.com/articles/compiling-mysql-on-snow-leopard/ Made all my problems go away.
I have to theories about your problem, but no reason to suspect either is really your cause, but they're quick checks.
You haven't properly defined the testing database in config/databases.yml
The mysql user that is attempting to build this database lacks the permission to do so.
Can you connect to the database in question with the credentials in question (all the stuff in database.yml)?
"mysql -u your_user -p" from the command line?
When you installed the mysql gem did it properly build the native extensions?
What happens when you gem install mysql --force (to re-install it)? Does it look happy?
Have you ever done this before? Is the problem as likely to be a lack of experience with rails/mysql or both? Or is this old hat and you just can't figure it out this time?
If the former, the tutorial in the pragramatic agile web development with rails is quite good (as is the rest of the book).
Hope something there helps.
Please tell the output of:
rake db:schema:load RAILS_ENV=test
to be sure that an existing database named _test is configured and working under config/database.yml