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

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/

Related

RSpec Test - Mysql2::Error::ConnectionError

Looks like my mysql2 gem is having difficulty connecting to a database. I can connect to mysql database easily using other mysql client tools. I checked the database connection string that is used for RSpec and it is correct. I get following error when I run a_spec.rb spec file.
Failure/Error: #db_client = DBClient.new
Mysql2::Error::ConnectionError:
SSL connection error: error:00000001:lib(0):func(0):reason(1)
# ./vendor/cache/ruby/2.3.0/gems/mysql2-0.5.2/lib/mysql2/client.rb:90:in `connect'
# ./vendor/cache/ruby/2.3.0/gems/mysql2-0.5.2/lib/mysql2/client.rb:90:in `initialize'
# ./helpers/db_client.rb:9:in `new'
# ./helpers/db_client.rb:9:in `initialize'
# ./v1/agent_summary_data_spec.rb:9:in `new'
# ./v1/agent_summary_data_spec.rb:9:in `block (3 levels) in <top (required)>'
# /Users/.rvm/gems/ruby-2.3.4/gems/bundler-1.16.2/lib/bundler/cli/exec.rb:74:in `load'
# /Users/.rvm/gems/ruby-2.3.4/gems/bundler-1.16.2/lib/bundler/cli/exec.rb:74:in `kernel_load'
# /Users/.rvm/gems/ruby-2.3.4/gems/bundler-1.16.2/lib/bundler/cli/exec.rb:28:in `run'
# /Users/.rvm/gems/ruby-2.3.4/gems/bundler-1.16.2/lib/bundler/cli.rb:424:in `exec'
# /Users/.rvm/gems/ruby-2.3.4/gems/bundler-1.16.2/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
# /Users/.rvm/gems/ruby-2.3.4/gems/bundler-1.16.2/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
# /Users/.rvm/gems/ruby-2.3.4/gems/bundler-1.16.2/lib/bundler/vendor/thor/lib/thor.rb:387:in `dispatch'
# /Users/.rvm/gems/ruby-2.3.4/gems/bundler-1.16.2/lib/bundler/cli.rb:27:in `dispatch'
# /Users/.rvm/gems/ruby-2.3.4/gems/bundler-1.16.2/lib/bundler/vendor/thor/lib/thor/base.rb:466:in `start'
# /Users/.rvm/gems/ruby-2.3.4/gems/bundler-1.16.2/lib/bundler/cli.rb:18:in `start'
# /Users/.rvm/gems/ruby-2.3.4/gems/bundler-1.16.2/exe/bundle:30:in `block in <top (required)>'
# /Users/.rvm/gems/ruby-2.3.4/gems/bundler-1.16.2/lib/bundler/friendly_errors.rb:124:in `with_friendly_errors'
# /Users/.rvm/gems/ruby-2.3.4/gems/bundler-1.16.2/exe/bundle:22:in `<top (required)>'
I am running following version of mysql in my machine
$ mysql --version
mysql Ver 8.0.12 for osx10.12 on x86_64 (Homebrew)
I am using following gem
$ gem which mysql2
/Users/.rvm/gems/ruby-2.3.4/gems/mysql2-0.5.2/lib/mysql2.rb
Any idea what might be going on? Wondering if anybody has faced similar problem.
Thanks!
In the end, I am able to resolve the above SSL issue. All I did was uninstalled and re-installed mysql2 gem using following commands. It did the magic.
bundle exec gem uninstall mysql2
bundle install

Rails MySQL Connection Problems

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.

WEBrick rails server (Psych::SyntaxError) | lynda.com tutorial

I'm a total newbie with RoR, so please forgive my density on this topic.
I'm trying to start the WEBrick application server using the rails server command, but I get the following error when I run it in my app directory /Users/Grace/Sites/simple_cms
I'm running the following:
Rails 3.2.13
ruby 2.0.0p0 (2013-02-24 revision 39474) [x86_64-darwin12.3.0]
OSX 10.8.3
Here's the error stack:
Grace$ rails server
=> 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/Grace/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/psych.rb:205:in `parse': (<unknown>): could not find expected ':' while scanning a simple key at line 18 column 3 (Psych::SyntaxError)
from /Users/Grace/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/psych.rb:205:in `parse_stream'
from /Users/Grace/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/psych.rb:153:in `parse'
from /Users/Grace/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/psych.rb:129:in `load'
from /Users/Grace/.rvm/gems/ruby-2.0.0-p0/gems/railties-3.2.13/lib/rails/application/configuration.rb:115:in `database_configuration'
from /Users/Grace/.rvm/gems/ruby-2.0.0-p0/gems/activerecord-3.2.13/lib/active_record/railtie.rb:78:in `block (2 levels) in <class:Railtie>'
from /Users/Grace/.rvm/gems/ruby-2.0.0-p0/gems/activesupport-3.2.13/lib/active_support/lazy_load_hooks.rb:36:in `instance_eval'
from /Users/Grace/.rvm/gems/ruby-2.0.0-p0/gems/activesupport-3.2.13/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook'
from /Users/Grace/.rvm/gems/ruby-2.0.0-p0/gems/activesupport-3.2.13/lib/active_support/lazy_load_hooks.rb:43:in `block in run_load_hooks'
from /Users/Grace/.rvm/gems/ruby-2.0.0-p0/gems/activesupport-3.2.13/lib/active_support/lazy_load_hooks.rb:42:in `each'
from /Users/Grace/.rvm/gems/ruby-2.0.0-p0/gems/activesupport-3.2.13/lib/active_support/lazy_load_hooks.rb:42:in `run_load_hooks'
from /Users/Grace/.rvm/gems/ruby-2.0.0-p0/gems/activerecord-3.2.13/lib/active_record/base.rb:720:in `<top (required)>'
from /Users/Grace/.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/Grace/.rvm/gems/ruby-2.0.0-p0/gems/railties-3.2.13/lib/rails/initializable.rb:30:in `instance_exec'
from /Users/Grace/.rvm/gems/ruby-2.0.0-p0/gems/railties-3.2.13/lib/rails/initializable.rb:30:in `run'
from /Users/Grace/.rvm/gems/ruby-2.0.0-p0/gems/railties-3.2.13/lib/rails/initializable.rb:55:in `block in run_initializers'
from /Users/Grace/.rvm/gems/ruby-2.0.0-p0/gems/railties-3.2.13/lib/rails/initializable.rb:54:in `each'
from /Users/Grace/.rvm/gems/ruby-2.0.0-p0/gems/railties-3.2.13/lib/rails/initializable.rb:54:in `run_initializers'
from /Users/Grace/.rvm/gems/ruby-2.0.0-p0/gems/railties-3.2.13/lib/rails/application.rb:136:in `initialize!'
from /Users/Grace/.rvm/gems/ruby-2.0.0-p0/gems/railties-3.2.13/lib/rails/railtie/configurable.rb:30:in `method_missing'
from /Users/Grace/Sites/simple_cms/config/environment.rb:5:in `<top (required)>'
from /Users/Grace/Sites/simple_cms/config.ru:3:in `require'
from /Users/Grace/Sites/simple_cms/config.ru:3:in `block in <main>'
from /Users/Grace/.rvm/gems/ruby-2.0.0-p0/gems/rack-1.4.5/lib/rack/builder.rb:51:in `instance_eval'
from /Users/Grace/.rvm/gems/ruby-2.0.0-p0/gems/rack-1.4.5/lib/rack/builder.rb:51:in `initialize'
from /Users/Grace/Sites/simple_cms/config.ru:in `new'
from /Users/Grace/Sites/simple_cms/config.ru:in `<main>'
from /Users/Grace/.rvm/gems/ruby-2.0.0-p0/gems/rack-1.4.5/lib/rack/builder.rb:40:in `eval'
from /Users/Grace/.rvm/gems/ruby-2.0.0-p0/gems/rack-1.4.5/lib/rack/builder.rb:40:in `parse_file'
from /Users/Grace/.rvm/gems/ruby-2.0.0-p0/gems/rack-1.4.5/lib/rack/server.rb:200:in `app'
from /Users/Grace/.rvm/gems/ruby-2.0.0-p0/gems/railties-3.2.13/lib/rails/commands/server.rb:46:in `app'
from /Users/Grace/.rvm/gems/ruby-2.0.0-p0/gems/rack-1.4.5/lib/rack/server.rb:304:in `wrapped_app'
from /Users/Grace/.rvm/gems/ruby-2.0.0-p0/gems/rack-1.4.5/lib/rack/server.rb:254:in `start'
from /Users/Grace/.rvm/gems/ruby-2.0.0-p0/gems/railties-3.2.13/lib/rails/commands/server.rb:70:in `start'
from /Users/Grace/.rvm/gems/ruby-2.0.0-p0/gems/railties-3.2.13/lib/rails/commands.rb:55:in `block in <top (required)>'
from /Users/Grace/.rvm/gems/ruby-2.0.0-p0/gems/railties-3.2.13/lib/rails/commands.rb:50:in `tap'
from /Users/Grace/.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>'
When I open up the psych.rb file I see this:
require 'psych.so'
require 'psych/nodes'
require 'psych/streaming'
require 'psych/visitors'
require 'psych/handler'
require 'psych/tree_builder'
require 'psych/parser'
require 'psych/omap'
require 'psych/set'
require 'psych/coder'
require 'psych/core_ext'
require 'psych/deprecated'
require 'psych/stream'
require 'psych/json/tree_builder'
require 'psych/json/stream'
require 'psych/handlers/document_stream'
###
# = Overview
#
# Psych is a YAML parser and emitter.
# Psych leverages libyaml [Home page: http://pyyaml.org/wiki/LibYAML]
# or [Git repo: https://github.com/zerotao/libyaml] for its YAML parsing
Please help! Thank you :)
Go into the database.yml file in your new rails project (if this is Lynda.com, that means it's the simple_cms project).
Make sure the keys on the left are followed by a colon, then a space, like this:
password: secret_phrase
And not like this, with no space after the colon:
password:secret_phrase
I also had the same problem and even though the indentations and spacings were correct in the database.yml I was still getting the errors. In my case the indentations were incorrect in the corresponding lines in application.yml.
Very good #Steel, but remove the space does not solve (increases the number of errors). But really this error indicates that the problem is in the database.yml.
In my case I had two statements socket.
Indentation of the code is important.
development:
adapter: mysql2
encoding: utf8
reconnect: false
database: xxx
pool: 5
username: xxx
password: xxx
socket: /socket_adress
test:
adapter: mysql2
encoding: utf8
reconnect: false
database: xxx
pool: 5
username: xxx
password: xxx
socket: /socket_adress
production:
adapter: mysql2
encoding: utf8
reconnect: false
database: xxx
pool: 5
username: xxx
password: xxx
socket: /socket_adress

Rails server fails to boot with mysql2 - Gems it requires, exists

This is me trying to use MySql on rails for the first time. This happens with using sqlite3 as well except it points to me do 'gem install activerecord-sqlite3-adapter`,the tells me there is no such gem named it.
I am using the lastest Ruby 2.0.
I am using the lastest Rails 3.2.13
I have the mysql2 (0.3.11) gem
I also have the activerecord-mysql2-adapter (0.0.3)
Yet... it is giving me the following message:
C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/rubygems_integration.rb:214:in 'block in replace_gem': Please install the mysql2 adapter: 'gem install activerecord-mysql2-adapter' (mysql2 is not part of the bundle. Add it to Gemfile.) (LoadError)
The bundler ran when I executed rails new [project name]
If it was mysql2 gem's error, this command successfully installs mysql2 on 64 bit Windows systems:gem install mysql2 -v '0.3.11' -- '--with-mysql-lib="C:\MySQL\lib" --with-mysql-include="C:\MySQL\include"'
Gemfile generated is using gem 'mysql2'ok, normal as I have been told.
Database.yml is as follows:
development:
adapter: mysql2
encoding: utf8
reconnect: false
database: shop_development
pool: 5
username: charlie
password: *******
host: localhost
And I have manually created a database called [projectname]_development.
C:\Users\Charlie\Documents\RailsProject\demo_app>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
C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/rubygems_integ
ration.rb:214:in `block in replace_gem': Please install the mysql2 adapter: `gem
install activerecord-mysql2-adapter` (mysql2 is not part of the bundle. Add it
to Gemfile.) (LoadError)
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activerecord-3.2.13/lib/act
ive_record/connection_adapters/mysql2_adapter.rb:3:in `<top (required)>'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-3.2.13/lib/ac
tive_support/dependencies.rb:251:in `require'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-3.2.13/lib/ac
tive_support/dependencies.rb:251:in `block in require'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-3.2.13/lib/ac
tive_support/dependencies.rb:236:in `load_dependency'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-3.2.13/lib/ac
tive_support/dependencies.rb:251:in `require'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activerecord-3.2.13/lib/act
ive_record/connection_adapters/abstract/connection_specification.rb:50:in `resol
ve_hash_connection'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activerecord-3.2.13/lib/act
ive_record/connection_adapters/abstract/connection_specification.rb:41:in `resol
ve_string_connection'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activerecord-3.2.13/lib/act
ive_record/connection_adapters/abstract/connection_specification.rb:25:in `spec'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activerecord-3.2.13/lib/act
ive_record/connection_adapters/abstract/connection_specification.rb:130:in `esta
blish_connection'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activerecord-3.2.13/lib/act
ive_record/railtie.rb:82:in `block (2 levels) in <class:Railtie>'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-3.2.13/lib/ac
tive_support/lazy_load_hooks.rb:36:in `instance_eval'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-3.2.13/lib/ac
tive_support/lazy_load_hooks.rb:36:in `execute_hook'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-3.2.13/lib/ac
tive_support/lazy_load_hooks.rb:43:in `block in run_load_hooks'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-3.2.13/lib/ac
tive_support/lazy_load_hooks.rb:42:in `each'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-3.2.13/lib/ac
tive_support/lazy_load_hooks.rb:42:in `run_load_hooks'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activerecord-3.2.13/lib/act
ive_record/base.rb:720:in `<top (required)>'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activerecord-3.2.13/lib/act
ive_record/railtie.rb:88:in `block in <class:Railtie>'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-3.2.13/lib/rails/i
nitializable.rb:30:in `instance_exec'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-3.2.13/lib/rails/i
nitializable.rb:30:in `run'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-3.2.13/lib/rails/i
nitializable.rb:55:in `block in run_initializers'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-3.2.13/lib/rails/i
nitializable.rb:54:in `each'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-3.2.13/lib/rails/i
nitializable.rb:54:in `run_initializers'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-3.2.13/lib/rails/a
pplication.rb:136:in `initialize!'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-3.2.13/lib/rails/r
ailtie/configurable.rb:30:in `method_missing'
from C:/Users/Charlie/Documents/RailsProject/demo_app/config/environment
.rb:5:in `<top (required)>'
from C:/Users/Charlie/Documents/RailsProject/demo_app/config.ru:3:in `re
quire'
from C:/Users/Charlie/Documents/RailsProject/demo_app/config.ru:3:in `bl
ock in <main>'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rack-1.4.5/lib/rack/builder
.rb:51:in `instance_eval'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rack-1.4.5/lib/rack/builder
.rb:51:in `initialize'
from C:/Users/Charlie/Documents/RailsProject/demo_app/config.ru:in `new'
from C:/Users/Charlie/Documents/RailsProject/demo_app/config.ru:in `<mai
n>'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rack-1.4.5/lib/rack/builder
.rb:40:in `eval'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rack-1.4.5/lib/rack/builder
.rb:40:in `parse_file'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rack-1.4.5/lib/rack/server.
rb:200:in `app'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-3.2.13/lib/rails/c
ommands/server.rb:46:in `app'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rack-1.4.5/lib/rack/server.
rb:304:in `wrapped_app'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rack-1.4.5/lib/rack/server.
rb:254:in `start'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-3.2.13/lib/rails/c
ommands/server.rb:70:in `start'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-3.2.13/lib/rails/c
ommands.rb:55:in `block in <top (required)>'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-3.2.13/lib/rails/c
ommands.rb:50:in `tap'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-3.2.13/lib/rails/c
ommands.rb:50:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
Check for following things
Does your Gemfile have the entry saying gem 'mysql2' ?
What happens when you run $ bundle update command? any errors
Can you try the following command to generate your app,
rails new demo_app -d mysql
What error you get when you try the above app?

How to install mysql on a new machine for an old app?

Not exactly sure how to go about this.
My app's database.yml
development:
adapter: mysql
encoding: utf8
reconnect: false
database: application-dev
pool: 5
username: root
password: angles123
socket: /tmp/mysql.sock
I was thinking that it would be wise to go ahead and mysqladmin -u root --password=angles123, and then once inside create database application-dev, but the -dev part, mysql is not happy about. But Icould create a database that said simply application.
Am I missing someting else possibly?
The reason I am bringing this up is because I get this error whenever I try to rake db:migrate, or script/server
rake db:test:prepare
(in /Users/macuser/Sites/hq_channel)
rake aborted!
uninitialized constant Geocode
So I assumed I set up the database wrong because I clearly have that gem installed.
Here is the full stacktrace :
rake aborted!
uninitialized constant Geocode
/Users/macuser/Sites/hq_channel/vendor/rails/activesupport/lib/active_support/dependencies.rb:443:in `load_missing_constant'
/Users/macuser/Sites/hq_channel/vendor/rails/activesupport/lib/active_support/dependencies.rb:80:in `const_missing_not_from_s3_library'
/Users/macuser/Sites/hq_channel/vendor/gems/aws-s3-0.6.2/lib/aws/s3/extensions.rb:206:in `const_missing'
/Users/macuser/Sites/hq_channel/vendor/rails/activesupport/lib/active_support/dependencies.rb:92:in `const_missing'
/Users/macuser/Sites/hq_channel/config/initializers/geocode.rb:1
/Users/macuser/Sites/hq_channel/vendor/rails/activesupport/lib/active_support/dependencies.rb:145:in `load_without_new_constant_marking'
/Users/macuser/Sites/hq_channel/vendor/rails/activesupport/lib/active_support/dependencies.rb:145:in `load'
/Users/macuser/Sites/hq_channel/vendor/rails/activesupport/lib/active_support/dependencies.rb:521:in `new_constants_in'
/Users/macuser/Sites/hq_channel/vendor/rails/activesupport/lib/active_support/dependencies.rb:145:in `load'
/Users/macuser/Sites/hq_channel/config/../vendor/rails/railties/lib/initializer.rb:622:in `load_application_initializers'
/Users/macuser/Sites/hq_channel/config/../vendor/rails/railties/lib/initializer.rb:621:in `each'
/Users/macuser/Sites/hq_channel/config/../vendor/rails/railties/lib/initializer.rb:621:in `load_application_initializers'
/Users/macuser/Sites/hq_channel/config/../vendor/rails/railties/lib/initializer.rb:176:in `process'
/Users/macuser/Sites/hq_channel/config/../vendor/rails/railties/lib/initializer.rb:113:in `send'
/Users/macuser/Sites/hq_channel/config/../vendor/rails/railties/lib/initializer.rb:113:in `run'
/Users/macuser/Sites/hq_channel/config/environment.rb:21
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
/Users/macuser/Sites/hq_channel/vendor/rails/activesupport/lib/active_support/dependencies.rb:156:in `require'
/Users/macuser/Sites/hq_channel/vendor/rails/activesupport/lib/active_support/dependencies.rb:521:in `new_constants_in'
/Users/macuser/Sites/hq_channel/vendor/rails/activesupport/lib/active_support/dependencies.rb:156:in `require'
/Users/macuser/Sites/hq_channel/vendor/rails/railties/lib/tasks/misc.rake:4
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `call'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `execute'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `each'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `execute'
/Library/Ruby/Gems/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'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:607:in `invoke_prerequisites'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:604:in `each'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:604:in `invoke_prerequisites'
/Library/Ruby/Gems/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'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:583:in `invoke'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2051:in `invoke_task'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `each'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2023:in `top_level'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2001:in `run'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:1998:in `run'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/bin/rake:31
/usr/bin/rake:19:in `load'
/usr/bin/rake:19
I've had mysql installations that didn't allow underscores or dashes in the database names.
You could try changing the database name to application and then running rake db:create to see if it creates your database.
Also, you can try running rake with --trace to get a better idea of what's being included from where that's causing that error.