Rails cannot connect to mysql server windows 10 - ruby-on-rails

I'm trying desperately to connect my new project / any project at all to the mysql2 server. I'm not really sure whether I've correctly installed MySQL server 5.7.21 or not but perhaps someone could advise.
I'm running ruby 2.3, rails 5.0.7 and mysql2 0.5.1. I definitely have mysql2 in my gemfile. I am running this on my 64-bit laptop with Windows 10
Every time I run a rails db:schema:dump from my project file in the command prompt, it shows this error:
C:\Users\MR_ra\Documents\Sites\matt_radin_cms>rails db:schema:dump --trace
** Invoke db:schema:dump (first_time)
** Invoke environment (first_time)
** Execute environment
** Invoke db:load_config (first_time)
** Execute db:load_config
** Execute db:schema:dump
rails aborted!
Mysql2::Error::ConnectionError: Can't connect to MySQL server on 'localhost'
(10061)
C:/Ruby23/lib/ruby/gems/2.3.0/gems/mysql2-0.5.1-x86-mingw32/lib/mysql2/client.rb:90:in `connect'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/mysql2-0.5.1-x86-mingw32/lib/mysql2/client.rb:90:in `initialize'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/activerecord-5.0.7/lib/active_record/connection_adapters/mysql2_adapter.rb:25:in `new'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/activerecord-5.0.7/lib/active_record/connection_adapters/mysql2_adapter.rb:25:in `mysql2_connection'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/activerecord-5.0.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:729:in `new_connection'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/activerecord-5.0.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:773:in `checkout_new_connection'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/activerecord-5.0.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:752:in `try_to_checkout_new_connection'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/activerecord-5.0.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:713:in `acquire_connection'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/activerecord-5.0.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:490:in `checkout'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/activerecord-5.0.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:364:in `connection'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/activerecord-5.0.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:883:in `retrieve_connection'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/activerecord-5.0.7/lib/active_record/connection_handling.rb:128:in `retrieve_connection'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/activerecord-5.0.7/lib/active_record/connection_handling.rb:91:in `connection'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/activerecord-5.0.7/lib/active_record/railties/databases.rake:241:in `block (4 levels) in <top (required)>'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/activerecord-5.0.7/lib/active_record/railties/databases.rake:240:in `open'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/activerecord-5.0.7/lib/active_record/railties/databases.rake:240:in `block (3 levels) in <top (required)>'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/task.rb:271:in `block in execute'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/task.rb:271:in `each'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/task.rb:271:in `execute'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/task.rb:213:in `block in invoke_with_call_chain'
C:/Ruby23/lib/ruby/2.3.0/monitor.rb:214:in `mon_synchronize'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/task.rb:193:in `invoke_with_call_chain'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/task.rb:182:in `invoke'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/application.rb:160:in `invoke_task'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/application.rb:116:in `block (2 levels) in top_level'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/application.rb:116:in `each'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/application.rb:116:in `block in top_level'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/application.rb:125:in `run_with_threads'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/application.rb:110:in `top_level'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/railties-5.0.7/lib/rails/commands/rake_proxy.rb:14:in `block in run_rake_task'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/application.rb:186:in `standard_exception_handling'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/railties-5.0.7/lib/rails/commands/rake_proxy.rb:11:in `run_rake_task'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/railties-5.0.7/lib/rails/commands/commands_tasks.rb:51:in `run_command!'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/railties-5.0.7/lib/rails/commands.rb:18:in `<top (required)>'
bin/rails:4:in `require'
bin/rails:4:in `<main>'
Tasks: TOP => db:schema:dump
Currently my databases.yml file is looking like this:
default: &default
adapter: mysql2
host: localhost
encoding: utf8
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
username: ***********
password: ***********
My question is also to answer what does the localhost 10061 refer to?

If your databases.yml file only like this which is you shared your question then you update little bit like this
default: &default
adapter: mysql2
host: localhost
encoding: utf8
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
username: xxxxxxxxxxx
password: xxxxxxxxxxx
#=> if live server
#=> socket: /var/run/mysqld/mysqld.sock
#=> for developmen
development:
<<: *default
database: project_development
#=> for test
test:
<<: *default
database: project_test
#=> for production
production:
<<: *default
database: project_production
username: xxxxxxxxxx
password: xxxxxxxxxx
then rails db:create
Actually, that is my configuration which already working
Note: If you developing locally and not set any password for mysql then username and password will look like this
username: root
password:
If you use WAMP or XAMPP you must run this before running rails command. The WAMP is recommended for windows.
that means by default username is root and password is empty.
You can by default set up this configuration if you will run this command for creating a Rails project
rails new project_name -d mysql

Related

Cannot connect rails and mysql2

So I'm trying to perform a simple database dump from the command prompt for the first time and the rails command keeps aborting with an error. This is running Ruby 2.3.0 with rails 5.0.7 and mysql 0.5.0.
C:\Users\MR_ra\Documents\Sites\matt_radin_cms>rails db:schema:dump --trace
** Invoke db:schema:dump (first_time)
** Invoke environment (first_time)
** Execute environment
** Invoke db:load_config (first_time)
** Execute db:load_config
** Execute db:schema:dump
rails aborted!
NameError: uninitialized constant Mysql2::Client::REMEMBER_OPTIONS
C:/Ruby23/lib/ruby/gems/2.3.0/gems/mysql2-0.5.0-x86-mingw32/lib/mysql2/client.rb:14:in `default_query_options'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/mysql2-0.5.0-x86-mingw32/lib/mysql2/client.rb:25:in `initialize'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/activerecord-5.0.7/lib/active_record/connection_adapters/mysql2_adapter.rb:25:in `new'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/activerecord-5.0.7/lib/active_record/connection_adapters/mysql2_adapter.rb:25:in `mysql2_connection'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/activerecord-5.0.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:729:in `new_connection'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/activerecord-5.0.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:773:in `checkout_new_connection'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/activerecord-5.0.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:752:in `try_to_checkout_new_connection'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/activerecord-5.0.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:713:in `acquire_connection'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/activerecord-5.0.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:490:in `checkout'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/activerecord-5.0.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:364:in `connection'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/activerecord-5.0.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:883:in `retrieve_connection'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/activerecord-5.0.7/lib/active_record/connection_handling.rb:128:in `retrieve_connection'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/activerecord-5.0.7/lib/active_record/connection_handling.rb:91:in `connection'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/activerecord-5.0.7/lib/active_record/railties/databases.rake:241:in `block (4 levels) in <top (required)>'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/activerecord-5.0.7/lib/active_record/railties/databases.rake:240:in `open'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/activerecord-5.0.7/lib/active_record/railties/databases.rake:240:in `block (3 levels) in <top (required)>'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/task.rb:271:in `block in execute'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/task.rb:271:in `each'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/task.rb:271:in `execute'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/task.rb:213:in `block in invoke_with_call_chain'
C:/Ruby23/lib/ruby/2.3.0/monitor.rb:214:in `mon_synchronize'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/task.rb:193:in `invoke_with_call_chain'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/task.rb:182:in `invoke'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/application.rb:160:in `invoke_task'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/application.rb:116:in `block (2 levels) in top_level'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/application.rb:116:in `each'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/application.rb:116:in `block in top_level'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/application.rb:125:in `run_with_threads'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/application.rb:110:in `top_level'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/railties-5.0.7/lib/rails/commands/rake_proxy.rb:14:in `block in run_rake_task'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/application.rb:186:in `standard_exception_handling'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/railties-5.0.7/lib/rails/commands/rake_proxy.rb:11:in `run_rake_task'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/railties-5.0.7/lib/rails/commands/commands_tasks.rb:51:in `run_command!'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/railties-5.0.7/lib/rails/commands.rb:18:in `<top (required)>'
bin/rails:4:in `require'
bin/rails:4:in `<main>'
Tasks: TOP => db:schema:dump
It's looking like no Mysql installed in your machine or adapter setting is wrong.
First install mysql server in your machine.
after that install mysql2 gem by below command or adding in application gemfile
gem install mysql2
gem 'mysql2'
then do below setting for your adapter
default: &default
adapter: mysql2
username: xxxxx
password: xxxxx
host: localhost
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
timeout: 5000
Hope this will help you out.
I think the problem with mysql2 gem version, you can define the version like this
gem 'mysql2', '~> 0.3.17'
then bundle install, it solved the problem on my hand.
The database.yml
default: &default
adapter: mysql2
host: localhost
encoding: unicode
username: root
password: #=> if you use password to your local databse then use otherwise empty this
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
development:
<<: *default
database: database_development

ActiveRecord::No Database Error Fatal: Role "..."does not exist

I'm working a project collaboratively with others. It is deployed to heroku and it we're using postgresql.
I want to make changes in a local branch and see my changes in the web browser right away.
How can I do this with heroku?
I'm working in Cloud9 development environment and I used to enter "rails s -p $PORT -b $IP" to view my changes in the app, but now when I do that, I get a "no database error."
I've tried googling things but I'm still confused. How can I make changes to an exisiting app and see my changes locally (without pushing to origin/master)? I've never worked with databases before... using the pre-programmed cloud9, things were just working. I'm not sure how to create a separate database for heroku if that's what is needed.
Here is a copy of my database.yml:
# SQLite version 3.x
# gem install sqlite3
#
# Ensure the SQLite 3 gem is defined in your Gemfile
# gem 'sqlite3'
#
# default: &default
# adapter: sqlite3
# pool: 5
# timeout: 5000
# development:
# <<: *default
# database: db/development.sqlite3
# # 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:
# <<: *default
# database: db/test.sqlite3
# production:
# <<: *default
# database: db/production.sqlite3
# FOR HEROKU -- POSTGRES DB SETUP
# UNCOMMENT WHEN WORKING LOCALLY.
development:
adapter: postgresql
database: planit_developement
pool: 5
timeout: 5000
test:
adapter: postgresql
database: planit_test
pool: 5
timeout: 5000
# production:
# <<: *default
# database: db/production.sqlite3
Here is the full trace when I try to migrate:
rake db:migrate --trace
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Invoke db:load_config (first_time)
** Execute db:load_config
** Execute db:migrate
rake aborted!
ActiveRecord::NoDatabaseError: FATAL: role "ubuntu" does not exist
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.2.4/lib/active_record/connection_adapters/postgresql_adapter.rb:665:in `rescue in connect'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.2.4/lib/active_record/connection_adapters/postgresql_adapter.rb:655:in `connect'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.2.4/lib/active_record/connection_adapters/postgresql_adapter.rb:242:in `initialize'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.2.4/lib/active_record/connection_adapters/postgresql_adapter.rb:44:in `new'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.2.4/lib/active_record/connection_adapters/postgresql_adapter.rb:44:in `postgresql_connection'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.2.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:438:in `new_connection'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.2.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:448:in `checkout_new_connection'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.2.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:422:in `acquire_connection'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.2.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:349:in `block in checkout'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.2.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:348:in `checkout'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.2.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:263:in `block in connection'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.2.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:262:in `connection'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.2.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:571:in `retrieve_connection'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.2.4/lib/active_record/connection_handling.rb:113:in `retrieve_connection'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.2.4/lib/active_record/connection_handling.rb:87:in `connection'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.2.4/lib/active_record/migration.rb:913:in `initialize'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.2.4/lib/active_record/migration.rb:820:in `new'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.2.4/lib/active_record/migration.rb:820:in `up'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.2.4/lib/active_record/migration.rb:798:in `migrate'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.2.4/lib/active_record/tasks/database_tasks.rb:137:in `migrate'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.2.4/lib/active_record/railties/databases.rake:44:in `block (2 levels) in <top (required)>'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:240:in `call'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:240:in `block in execute'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:235:in `each'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:235:in `execute'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:179:in `block in invoke_with_call_chain'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:172:in `invoke_with_call_chain'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:165:in `invoke'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:150:in `invoke_task'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:106:in `block (2 levels) in top_level'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:106:in `each'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:106:in `block in top_level'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:115:in `run_with_threads'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:100:in `top_level'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:78:in `block in run'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:176:in `standard_exception_handling'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:75:in `run'
Tasks: TOP => db:migrate

Why is Rake aborting because of "Bad file Descriptor"?

I have a problem creating a database using rake db:create.
I followed the "Fat Free CRM Guides: Installation on Microsoft Windows" guide to install the Fat Free CRM on Windows.
I am on 32-bit Windows 7. Rake is 0.8.7. RubyGems is 2.0.3 and Ruby is 1.9.3. I am using MySQL2 v0.2.6.
The error I got was:
C:\RailsInstaller\fat_free_crm>rake db:create RAILS_ENV=production --trace
** Invoke db:create (first_time)
** Invoke db:load_config (first_time)
** Execute db:load_config
** Invoke rails_env (first_time)
** Execute rails_env
** Execute db:create
rake aborted!
Bad file descriptor
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mysql2-0.2.6-x86-mingw32/lib/active_record/connection_adapters/mysql2_adapter.rb:312:in `query'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mysql2-0.2.6-x86-mingw32/lib/active_record/connection_adapters/mysql2_adapter.rb:312:in `execute'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mysql2-0.2.6-x86-mingw32/lib/active_record/connection_adapters/mysql2_adapter.rb:629:in `configure_connecti
on'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mysql2-0.2.6-x86-mingw32/lib/active_record/connection_adapters/mysql2_adapter.rb:169:in `initialize'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mysql2-0.2.6-x86-mingw32/lib/active_record/connection_adapters/mysql2_adapter.rb:16:in `new'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mysql2-0.2.6-x86-mingw32/lib/active_record/connection_adapters/mysql2_adapter.rb:16:in `mysql2_connection'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:315:in `new_connectio
n'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:325:in `checkout_new_
connection'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:247:in `block (2 leve
ls) in checkout'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:242:in `loop'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:242:in `block in chec
kout'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:239:in `checkout'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:102:in `block in conn
ection'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:101:in `connection'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:410:in `retrieve_conn
ection'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_specification.rb:171:in `retr
ieve_connection'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_specification.rb:145:in `conn
ection'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/railties/databases.rake:120:in `rescue in create_database'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/railties/databases.rake:85:in `create_database'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/railties/databases.rake:62:in `block (3 levels) in <top (required)>'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/railties/databases.rake:62:in `each'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/railties/databases.rake:62:in `block (2 levels) in <top (required)>'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:246:in `call'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:246:in `block in execute'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:241:in `each'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:241:in `execute'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:184:in `block in invoke_with_call_chain'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:177:in `invoke_with_call_chain'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:170:in `invoke'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:143:in `invoke_task'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:101:in `block (2 levels) in top_level'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:101:in `each'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:101:in `block in top_level'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/applic....
C:/RailsInstaller/Ruby1.9.3/bin/rake:23:in `load'
C:/RailsInstaller/Ruby1.9.3/bin/rake:23:in `<main>'
Tasks: TOP => db:create
C:\RailsInstaller\fat_free_crm>[/code]
I changed libmysql.dll for win7 - 32bit
The configuration of database.yml is:
development:
adapter: mysql2
encoding: utf8
database: fat_free_crm_development
pool: 5
username: root
password: ale
#socket: /var/run/mysqld/mysqld.sock
host: localhost
#host: 127.0.0.1
port: 3306
test:
#<<: *development
database: fat_free_crm_test
production:
#<<: *development
adapter: mysql2
encoding: utf8
#database: crm_production
database: fat_free_crm_production
pool: 5
username: root
password: ale
#socket: /tmp/mysql.sock
#host: 127.0.0.1
host: localhost
port: 3306
staging:
#<<: *development
database: fat_free_crm_staging
Does anyone have any ideas?
At lines 9, 25, 29, 43 remove &development and <<*development. I think you have syntax errors in your database.yml file.

Trouble installing gitlab-5.0 - rake aborted

Trouble installing gitlab-5.0
https://github.com/gitlabhq/gitlabhq/blob/5-0-stable/doc/install/installation.md#initialise-database-and-activate-advanced-features
root#ubuntu:/home/gitlab/gitlab# bundle exec rake gitlab:setup RAILS_ENV=production
rake aborted!
Access denied for user 'root'#'localhost' (using password: YES)
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/mysql2-0.3.11/lib/mysql2/client.rb:44:in `connect'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/mysql2-0.3.11/lib/mysql2/client.rb:44:in `initialize'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/mysql2_adapter.rb:16:in `new'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/mysql2_adapter.rb:16:in `mysql2_connection'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:315:in `new_connection'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:325:in `checkout_new_connection'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:247:in `block (2 levels) in checkout'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:242:in `loop'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:242:in `block in checkout'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:239:in `checkout'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:102:in `block in connection'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:101:in `connection'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:410:in `retrieve_connection'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_specification.rb:171:in `retrieve_connection'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_specification.rb:145:in `connection'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/model_schema.rb:308:in `clear_cache!'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/railtie.rb:104:in `block (2 levels) in <class:Railtie>'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:418:in `_run__807030537706508428__prepare__2182945095053453794__callbacks'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:405:in `__run_callback'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:385:in `_run_prepare_callbacks'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:81:in `run_callbacks'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_dispatch/middleware/reloader.rb:74:in `prepare!'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_dispatch/middleware/reloader.rb:48:in `prepare!'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/application/finisher.rb:47:in `block in <module:Finisher>'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/initializable.rb:30:in `instance_exec'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/initializable.rb:30:in `run'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/initializable.rb:55:in `block in run_initializers'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/initializable.rb:54:in `each'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/initializable.rb:54:in `run_initializers'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/application.rb:136:in `initialize!'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/railtie/configurable.rb:30:in `method_missing'
/home/gitlab/gitlab/config/environment.rb:5:in `<top (required)>'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/backports-2.6.7/lib/backports/tools.rb:314:in `require'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/backports-2.6.7/lib/backports/tools.rb:314:in `require_with_backports'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `block in require'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:236:in `load_dependency'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `require'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/application.rb:103:in `require_environment!'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/application.rb:297:in `block (2 levels) in initialize_tasks'
Tasks: TOP => gitlab:setup => environment
(See full trace by running task with --trace)
Some idea?
If you are following the tutorial and followed the steps for the MySQL database setup then you have configured the database to use gitlab for the user name.
# Create a user for GitLab. (change $password to a real password)
mysql> CREATE USER 'gitlab'#'localhost' IDENTIFIED BY '$password';
but if your database.yml file is attempting to log into the database using the root credentials.
production:
adapter: mysql2
encoding: utf8
reconnect: false
database: gitlabhq_production
pool: 5
username: root
password: "secure password"
# host: localhost
# socket: /tmp/mysql.sock
That is why you would see that error.
Change your database.yml file to reflect the login created in the database setup portion of the tutorial.
production:
adapter: mysql2
encoding: utf8
reconnect: false
database: gitlabhq_production
pool: 5
username: gitlab
password: "$password"
# host: localhost
# socket: /tmp/mysql.sock
That section Initialise Database and Activate Advanced Features is:
sudo -u git -H bundle exec rake gitlab:setup RAILS_ENV=production
That means you are supposed to execute that command as git, not as root (which hasn't been granted access to the database).
Make sure though that your database.yml config file looks like this one (if you have mysql installed and want to use a mysql database).
production:
adapter: mysql2
encoding: utf8
reconnect: false
database: gitlabhq_production
pool: 5
username: root
password: "secure password"
# host: localhost
# socket: /tmp/mysql.sock
It does declare an access for an account root, but this is purely a declarative mysql account (nothing to do with the user root)

rake aborted! syntax error on line 1, col 9: ` adapter: sqlite3'

I'm trying to use mysql as a database in production enviroment as sugested on page 234, chapter 16 of my Agile 4rth edition. As far as I know that this question looks like the one that danymmc asked on january (http://stackoverflow.com/questions/8809099/rails-app-rake-dbmigrate-aborted-syntax-error) the solution doesn't fit to me.
I'm working with:
Ruby 1.9.2
Rails 3.1.0
rubygems 1.8.18
My database.yml is:
development:
adapter: sqlite3
database: development
pool: 5
timeout: 5000
production:
adapter: mysql
database: depot_production
encoding: utf8
host: localhost
password: password
pool: 5
reconnect: false
socket: /var/run/mysqld/mysqld.sock
username: username
test:
adapter: sqlite3
database: db/test.sqlite3
pool: 5
timeout: 5000
When I trace the rake db:setup RAILS_ENV="production" I get:
root#HAL3:/var/www/repos/depot/depot_old# rake db:setup RAILS_ENV="production" --trace
** Invoke db:setup (first_time)
** 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!
syntax error on line 1, col 9: ` adapter: sqlite3'
/usr/local/rvm/rubies/ruby-1.9.2-p318/lib/ruby/1.9.1/syck.rb:135:in `load'
/usr/local/rvm/rubies/ruby-1.9.2-p318/lib/ruby/1.9.1/syck.rb:135:in `load'
/usr/local/rvm/gems/ruby-1.9.2-p318/gems/railties-3.1.0/lib/rails/application/configuration.rb:100:in `database_configuration'
/usr/local/rvm/gems/ruby-1.9.2-p318/gems/activerecord-3.1.0/lib/active_record/railties/databases.rake:6:in `block (2 levels) in <top (required)>'
/usr/local/rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `call'
/usr/local/rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `block in execute'
/usr/local/rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `each'
/usr/local/rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute'
/usr/local/rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain'
/usr/local/rvm/rubies/ruby-1.9.2-p318/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/usr/local/rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/usr/local/rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/task.rb:176:in `block in invoke_prerequisites'
/usr/local/rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/task.rb:174:in `each'
/usr/local/rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/task.rb:174:in `invoke_prerequisites'
/usr/local/rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/task.rb:157:in `block in invoke_with_call_chain'
/usr/local/rvm/rubies/ruby-1.9.2-p318/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/usr/local/rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/usr/local/rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/task.rb:176:in `block in invoke_prerequisites'
/usr/local/rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/task.rb:174:in `each'
/usr/local/rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/task.rb:174:in `invoke_prerequisites'
/usr/local/rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/task.rb:157:in `block in invoke_with_call_chain'
/usr/local/rvm/rubies/ruby-1.9.2-p318/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/usr/local/rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/usr/local/rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke'
/usr/local/rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/application.rb:116:in `invoke_task'
/usr/local/rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block (2 levels) in top_level'
/usr/local/rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `each'
/usr/local/rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block in top_level'
/usr/local/rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/usr/local/rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/application.rb:88:in `top_level'
/usr/local/rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/application.rb:66:in `block in run'
/usr/local/rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/usr/local/rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
/usr/local/rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/bin/rake:33:in `<top (required)>'
/usr/local/rvm/gems/ruby-1.9.2-p318/bin/rake:19:in `load'
/usr/local/rvm/gems/ruby-1.9.2-p318/bin/rake:19:in `<main>'
Tasks: TOP => db:setup => db:create => db:load_config
I tried to include this code to the config/boot.rb file and it doens't worked:
require 'yaml'
YAML::ENGINE.yamler = 'syck'
I tried to update my gems with
gem update -system
and it doesn't work too.
The most interesting thing is that my development machine and the production one are the same and, of course, in development (localhost:3000 with rails server up) works perfectly.
Any help will be appreciated.
Try with this database.yml:
development:
adapter: sqlite3
database: development
pool: 5
timeout: 5000
production:
adapter: mysql
database: depot_production
encoding: utf8
host: localhost
password: password
pool: 5
reconnect: false
socket: /var/run/mysqld/mysqld.sock
username: username
test:
adapter: sqlite3
database: db/test.sqlite3
pool: 5
timeout: 5000
Mind the spaces, that are significant
The issue could be that you have your test environment nested 1 space too deep causing invalid YML. Make sure it is indented 2 spaces rather than 3.
You can use hostname: instead of host in database.yml file.

Resources