Mac OSX Rails Can not run Rake Command - mysql

I am trying to run rake command to build the db for my project. but i am encoutering the following error.
Harshas-MacBook-Pro:noise harshamv$ rake db:create
Couldn't create database for {"adapter"=>"mysql2", "encoding"=>"utf8", "database"=>"noise_development", "pool"=>5, "username"=>"hmv", "password"=>2206, "socket"=>"/var/run/mysqld/mysqld.sock"}, {:charset=>"utf8", :collation=>"utf8_unicode_ci"}
(If you set the charset manually, make sure you have a matching collation)
Couldn't create database for {"adapter"=>"mysql2", "encoding"=>"utf8", "database"=>"noise_test", "pool"=>5, "username"=>"root", "password"=>"root", "socket"=>"/var/run/mysqld/mysqld.sock"}, {:charset=>"utf8", :collation=>"utf8_unicode_ci"}
(If you set the charset manually, make sure you have a matching collation)
Rake db:migrate
Harshas-MacBook-Pro:noise harshamv$ rake db:migrate
rake aborted!
Mysql2::Error: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
/Users/harshamv/.rvm/gems/ruby-2.1.2/gems/mysql2-0.3.15/lib/mysql2/client.rb:67:in `connect'
/Users/harshamv/.rvm/gems/ruby-2.1.2/gems/mysql2-0.3.15/lib/mysql2/client.rb:67:in `initialize'
/Users/harshamv/.rvm/gems/ruby-2.1.2/gems/activerecord-4.0.0/lib/active_record/connection_adapters/mysql2_adapter.rb:18:in `new'
/Users/harshamv/.rvm/gems/ruby-2.1.2/gems/activerecord-4.0.0/lib/active_record/connection_adapters/mysql2_adapter.rb:18:in `mysql2_connection'
/Users/harshamv/.rvm/gems/ruby-2.1.2/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:440:in `new_connection'
/Users/harshamv/.rvm/gems/ruby-2.1.2/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:450:in `checkout_new_connection'
/Users/harshamv/.rvm/gems/ruby-2.1.2/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:421:in `acquire_connection'
/Users/harshamv/.rvm/gems/ruby-2.1.2/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:356:in `block in checkout'
/Users/harshamv/.rvm/gems/ruby-2.1.2/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:355:in `checkout'
/Users/harshamv/.rvm/gems/ruby-2.1.2/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:265:in `block in connection'
/Users/harshamv/.rvm/gems/ruby-2.1.2/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:264:in `connection'
/Users/harshamv/.rvm/gems/ruby-2.1.2/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:546:in `retrieve_connection'
/Users/harshamv/.rvm/gems/ruby-2.1.2/gems/activerecord-4.0.0/lib/active_record/connection_handling.rb:79:in `retrieve_connection'
/Users/harshamv/.rvm/gems/ruby-2.1.2/gems/activerecord-4.0.0/lib/active_record/connection_handling.rb:53:in `connection'
/Users/harshamv/.rvm/gems/ruby-2.1.2/gems/activerecord-4.0.0/lib/active_record/migration.rb:863:in `initialize'
/Users/harshamv/.rvm/gems/ruby-2.1.2/gems/activerecord-4.0.0/lib/active_record/migration.rb:764:in `new'
/Users/harshamv/.rvm/gems/ruby-2.1.2/gems/activerecord-4.0.0/lib/active_record/migration.rb:764:in `up'
/Users/harshamv/.rvm/gems/ruby-2.1.2/gems/activerecord-4.0.0/lib/active_record/migration.rb:742:in `migrate'
/Users/harshamv/.rvm/gems/ruby-2.1.2/gems/activerecord-4.0.0/lib/active_record/railties/databases.rake:42:in `block (2 levels) in <top (required)>'
/Users/harshamv/.rvm/gems/ruby-2.1.2/bin/ruby_executable_hooks:15:in `eval'
/Users/harshamv/.rvm/gems/ruby-2.1.2/bin/ruby_executable_hooks:15:in `<main>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
But i am able to get connected into mysql from the CLI.
This is my Rails Configuration File
development:
adapter: mysql2
encoding: utf8
database: noise_development
pool: 5
username: hmv
password: *******
socket: /var/run/mysqld/mysqld.sock

Related

Rails rake db:migrate aborted on a read-only mysql database

I have a problem when working with Rails' rake db:migrate. I want a connection to an existing external MySQL database, and have configured my database.yml into this:
default: &default
adapter: mysql
pool: 5
timeout: 5000
development:
adapter: mysql
host: [my_host]
username: [my_user]
password: [my_pass]
database: [my_db]
test:
<<: *default
database: db/test.sqlite3
production:
<<: *default
database: db/production.sqlite3
Then I shut down the Rails' server and ran rails server again to see if my connection goes well. I'm still working locally, in development mode. However, I got ActiveRecord::PendingMigrationError. Trying to follow the advice, the process was aborted instead. Here is the snapshot.
And the trace.
Mac-User:rails-test user$ bin/rake db:migrate RAILS_ENV=development
rake aborted!
ActiveRecord::StatementInvalid: Mysql::Error: The MySQL server is running with the --read-only option so it cannot execute this statement: CREATE TABLE `schema_migrations` (`version` varchar(255) NOT NULL) ENGINE=InnoDB
/Users/ruma/.rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:303:in `query'
/Users/ruma/.rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:303:in `block in execute'
/Users/ruma/.rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/connection_adapters/abstract_adapter.rb:373:in `block in log'
/Users/ruma/.rvm/gems/ruby-2.1.3/gems/activesupport-4.1.6/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/Users/ruma/.rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/connection_adapters/abstract_adapter.rb:367:in `log'
/Users/ruma/.rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:303:in `execute'
/Users/ruma/.rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/connection_adapters/abstract/schema_statements.rb:205:in `create_table'
/Users/ruma/.rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:460:in `create_table'
/Users/ruma/.rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/schema_migration.rb:29:in `create_table'
/Users/ruma/.rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/connection_adapters/abstract/schema_statements.rb:656:in `initialize_schema_migrations_table'
/Users/ruma/.rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/migration.rb:918:in `initialize'
/Users/ruma/.rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/migration.rb:807:in `new'
/Users/ruma/.rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/migration.rb:807:in `up'
/Users/ruma/.rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/migration.rb:785:in `migrate'
/Users/ruma/.rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/railties/databases.rake:34:in `block (2 levels) in <top (required)>'
/Users/ruma/.rvm/gems/ruby-2.1.3/gems/activesupport-4.1.6/lib/active_support/dependencies.rb:241:in `load'
/Users/ruma/.rvm/gems/ruby-2.1.3/gems/activesupport-4.1.6/lib/active_support/dependencies.rb:241:in `block in load'
/Users/ruma/.rvm/gems/ruby-2.1.3/gems/activesupport-4.1.6/lib/active_support/dependencies.rb:232:in `load_dependency'
/Users/ruma/.rvm/gems/ruby-2.1.3/gems/activesupport-4.1.6/lib/active_support/dependencies.rb:241:in `load'
-e:1:in `<main>'
Mysql::Error: The MySQL server is running with the --read-only option so it cannot execute this statement
/Users/ruma/.rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:303:in `query'
/Users/ruma/.rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:303:in `block in execute'
/Users/ruma/.rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/connection_adapters/abstract_adapter.rb:373:in `block in log'
/Users/ruma/.rvm/gems/ruby-2.1.3/gems/activesupport-4.1.6/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/Users/ruma/.rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/connection_adapters/abstract_adapter.rb:367:in `log'
/Users/ruma/.rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:303:in `execute'
/Users/ruma/.rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/connection_adapters/abstract/schema_statements.rb:205:in `create_table'
/Users/ruma/.rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:460:in `create_table'
/Users/ruma/.rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/schema_migration.rb:29:in `create_table'
/Users/ruma/.rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/connection_adapters/abstract/schema_statements.rb:656:in `initialize_schema_migrations_table'
/Users/ruma/.rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/migration.rb:918:in `initialize'
/Users/ruma/.rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/migration.rb:807:in `new'
/Users/ruma/.rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/migration.rb:807:in `up'
/Users/ruma/.rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/migration.rb:785:in `migrate'
/Users/ruma/.rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/railties/databases.rake:34:in `block (2 levels) in <top (required)>'
/Users/ruma/.rvm/gems/ruby-2.1.3/gems/activesupport-4.1.6/lib/active_support/dependencies.rb:241:in `load'
/Users/ruma/.rvm/gems/ruby-2.1.3/gems/activesupport-4.1.6/lib/active_support/dependencies.rb:241:in `block in load'
/Users/ruma/.rvm/gems/ruby-2.1.3/gems/activesupport-4.1.6/lib/active_support/dependencies.rb:232:in `load_dependency'
/Users/ruma/.rvm/gems/ruby-2.1.3/gems/activesupport-4.1.6/lib/active_support/dependencies.rb:241:in `load'
-e:1:in `<main>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
My concern is the command was going to do some CREATE TABLE while the external database is read-only. Can anyone figure out how to pass or skip the db:migrate? I'm not going to update any single thing on the database anyway.
Your respond will be very appreciated. Thanks!

Rails application unable to connect to mysql, Can't connect to local MySQL server through socket '/var/run/mysqld/mysql.sock' (2) (Mysql2::Error)

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/

Rails 3.2.2 mysql2 adapter Error

I've been having trouble getting the mysql2 adapter working with the latest version of rails. I Just generated a new project. Added the following to my gemfile:
gem 'mysql2', '< 0.3.7'
then of course ran:
bundle install
I also modified my database.yml file:
development:
adapter: mysql2
encoding: utf8
database: blog_development
username: root
password: *********
socket: /tmp/mysql.sock
test:
adapter: mysql2
encoding: utf8
database: blog_test
username: root
password: ********
socket: /tmp/mysql.sock
production:
adapter: mysql2
encoding: utf8
database: blog_production
username: root
password: *********
socket: /tmp/mysql.sock
So when I try and run rake db:create, the following is the output.
$ rake db:create --trace
** 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!
Please install the mysql2 adapter: `gem install activerecord-mysql2-adapter` (can't activate mysql2 (~> 0.3.10), already activated mysql2-0.3.6. Make sure all dependencies are added to Gemfile.)
/Users/teddyknox/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.3/lib/bundler/rubygems_integration.rb:157:in `block in replace_gem'
/Users/teddyknox/.rvm/gems/ruby-1.9.3-p125/gems/activerecord-3.2.2/lib/active_record/connection_adapters/mysql2_adapter.rb:3:in `<top (required)>'
/Users/teddyknox/.rvm/gems/ruby-1.9.3-p125/gems/activesupport-3.2.2/lib/active_support/dependencies.rb:251:in `require'
/Users/teddyknox/.rvm/gems/ruby-1.9.3-p125/gems/activesupport-3.2.2/lib/active_support/dependencies.rb:251:in `block in require'
/Users/teddyknox/.rvm/gems/ruby-1.9.3-p125/gems/activesupport-3.2.2/lib/active_support/dependencies.rb:236:in `load_dependency'
/Users/teddyknox/.rvm/gems/ruby-1.9.3-p125/gems/activesupport-3.2.2/lib/active_support/dependencies.rb:251:in `require'
/Users/teddyknox/.rvm/gems/ruby-1.9.3-p125/gems/activerecord-3.2.2/lib/active_record/connection_adapters/abstract/connection_specification.rb:48:in `resolve_hash_connection'
/Users/teddyknox/.rvm/gems/ruby-1.9.3-p125/gems/activerecord-3.2.2/lib/active_record/connection_adapters/abstract/connection_specification.rb:27:in `spec'
/Users/teddyknox/.rvm/gems/ruby-1.9.3-p125/gems/activerecord-3.2.2/lib/active_record/connection_adapters/abstract/connection_specification.rb:127:in `establish_connection'
/Users/teddyknox/.rvm/gems/ruby-1.9.3-p125/gems/activerecord-3.2.2/lib/active_record/railties/databases.rake:67:in `create_database'
/Users/teddyknox/.rvm/gems/ruby-1.9.3-p125/gems/activerecord-3.2.2/lib/active_record/railties/databases.rake:40:in `block (3 levels) in <top (required)>'
/Users/teddyknox/.rvm/gems/ruby-1.9.3-p125/gems/activerecord-3.2.2/lib/active_record/railties/databases.rake:40:in `each'
/Users/teddyknox/.rvm/gems/ruby-1.9.3-p125/gems/activerecord-3.2.2/lib/active_record/railties/databases.rake:40:in `block (2 levels) in <top (required)>'
/Users/teddyknox/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `call'
/Users/teddyknox/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `block in execute'
/Users/teddyknox/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `each'
/Users/teddyknox/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute'
/Users/teddyknox/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain'
/Users/teddyknox/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/Users/teddyknox/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/Users/teddyknox/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke'
/Users/teddyknox/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/application.rb:116:in `invoke_task'
/Users/teddyknox/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block (2 levels) in top_level'
/Users/teddyknox/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `each'
/Users/teddyknox/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block in top_level'
/Users/teddyknox/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/Users/teddyknox/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/application.rb:88:in `top_level'
/Users/teddyknox/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/application.rb:66:in `block in run'
/Users/teddyknox/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/Users/teddyknox/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
/Users/teddyknox/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/bin/rake:33:in `<top (required)>'
/Users/teddyknox/.rvm/gems/ruby-1.9.3-p125/bin/rake:19:in `load'
/Users/teddyknox/.rvm/gems/ruby-1.9.3-p125/bin/rake:19:in `<main>'
Tasks: TOP => db:create
It's telling me to install:
gem install activerecord-mysql2-adapter
But this gem doesn't exist. I'm pretty confused. I've tried many different versions of mysql2 and none seem to work. Any ideas?
Using the following in the gemfile seemed to work:
gem "mysql2", "~> 0.3.11"
It looks like one of your gems requires mysql2 ~> 0.3.10 (meaning >= 0.3.10 && < 0.4), while you are requiring it < 0.3.7. Try removing the constraint on the version and bundle install again ?

Rails rake db:create not working

Hey everyone! I am having trouble setting up a MySQL database for my rails application. Here are the contents of my database.yml file:
development:
  adapter: mysql
  encoding: utf8
reconnect: false
  database: app_name_dev
  pool: 5
  username: root
  password:
  socket: /tmp/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: mysql
  encoding: utf8
reconnect: false
  database: app_name_test
  pool: 5
  username: root
  password:
  socket: /tmp/mysql.sock
production:
  adapter: mysql
  encoding: utf8
reconnect: false
  database: app_name_pro
  pool: 5
  username: root
  password:
  socket: /tmp/mysql.sock
I also replaced gem sqlite3 with gem mysql in my gemfile and ran bundle install. Now I am trying to create the database for the first time with rake db:create. I am getting the following error:
$ rake db:create --trace
(in c:/Users/Kvass/documents/programming/ruby/app_name)
** Invoke db:create (first_time)
** Invoke db:load_config (first_time)
** Invoke rails_env (first_time)
** Execute rails_env
** Execute db:load_config
rake aborted!
couldn't parse YAML at line 1 column 0
c:/Ruby192/lib/ruby/1.9.1/psych.rb:148:in `parse'
c:/Ruby192/lib/ruby/1.9.1/psych.rb:148:in `parse_stream'
c:/Ruby192/lib/ruby/1.9.1/psych.rb:119:in `parse'
c:/Ruby192/lib/ruby/1.9.1/psych.rb:106:in `load'
c:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.7/lib/rails/application/configu
ration.rb:88:in `database_configuration'
c:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.0.7/lib/active_record/railtie
s/databases.rake:4:in `block (2 levels) in <top (required)>'
c:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:636:in `call'
c:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:636:in `block in exec
ute'
c:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:631:in `each'
c:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:631:in `execute'
c:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:597:in `block in invo
ke_with_call_chain'
c:/Ruby192/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
c:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_c
all_chain'
c:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:607:in `block in invo
ke_prerequisites'
c:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:604:in `each'
c:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:604:in `invoke_prereq
uisites'
c:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:596:in `block in invo
ke_with_call_chain'
c:/Ruby192/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
c:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_c
all_chain'
c:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:583:in `invoke'
c:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:2051:in `invoke_task'
c:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:2029:in `block (2 lev
els) in top_level'
c:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:2029:in `each'
c:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:2029:in `block in top
_level'
c:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exc
eption_handling'
c:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:2023:in `top_level'
c:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:2001:in `block in run
'
c:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exc
eption_handling'
c:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:1998:in `run'
c:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.8.7/bin/rake:31:in `<top (required)>'
c:/Ruby192/bin/rake:19:in `load'
c:/Ruby192/bin/rake:19:in `<main>'
Can someone please explain what I am doing wrong? Thanks!
The MySQL server had not been running on my machine when I tried to run rake db:create. Careless mistake :P
Try using this as your database.yml:
# SQLite version 3.x
# gem install sqlite3-ruby (not necessary on OS X Leopard)
development:
adapter: sqlite3
database: db/development.sqlite3
pool: 5
timeout: 5000
# 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: &TEST
adapter: sqlite3
database: db/test.sqlite3
pool: 5
timeout: 5000
production:
adapter: sqlite3
database: db/production.sqlite3
pool: 5
timeout: 5000
cucumber:
<<: *TEST
In my development process i use this config:
development:
adapter: mysql2
database: my_db
encoding: utf8
username: rails
password: rails
host: localhost

Problem with rake db:migrate -

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.