Im following the ruby on rails course from Lynda, where I have problems connecting to the database using the command line in windows.
I can connect to the database using "mysql -u username -p" and entering the password afterwards. I can create databases and all without problem.
Now when executing:
rake db:schema:dump
in my application folder "simple_cms" I get the following:
rake aborted!
Can't connect to MySQL server on 'localhost' (10061)
Tasks: TOP => db:schema:dump
(See full trace by running task with --trace)
Running the trace gives:
C:\Users\ASUS\Desktop\simple_cms>rake 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
rake aborted!
Can't connect to MySQL server on 'localhost' (10061)
C:/Ruby192/lib/ruby/gems/1.9.1/gems/mysql2-0.3.11-x86-mingw32/lib/mysql2/client.
rb:44:in `connect'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/mysql2-0.3.11-x86-mingw32/lib/mysql2/client.
rb:44:in `initialize'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.2.10/lib/active_record/connec
tion_adapters/mysql2_adapter.rb:16:in `new'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.2.10/lib/active_record/connec
tion_adapters/mysql2_adapter.rb:16:in `mysql2_connection'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.2.10/lib/active_record/connec
tion_adapters/abstract/connection_pool.rb:315:in `new_connection'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.2.10/lib/active_record/connec
tion_adapters/abstract/connection_pool.rb:325:in `checkout_new_connection'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.2.10/lib/active_record/connec
tion_adapters/abstract/connection_pool.rb:247:in `block (2 levels) in checkout'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.2.10/lib/active_record/connec
tion_adapters/abstract/connection_pool.rb:242:in `loop'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.2.10/lib/active_record/connec
tion_adapters/abstract/connection_pool.rb:242:in `block in checkout'
C:/Ruby192/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.2.10/lib/active_record/connec
tion_adapters/abstract/connection_pool.rb:239:in `checkout'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.2.10/lib/active_record/connec
tion_adapters/abstract/connection_pool.rb:102:in `block in connection'
C:/Ruby192/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.2.10/lib/active_record/connec
tion_adapters/abstract/connection_pool.rb:101:in `connection'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.2.10/lib/active_record/connec
tion_adapters/abstract/connection_pool.rb:410:in `retrieve_connection'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.2.10/lib/active_record/connec
tion_adapters/abstract/connection_specification.rb:171:in `retrieve_connection'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.2.10/lib/active_record/connec
tion_adapters/abstract/connection_specification.rb:145:in `connection'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.2.10/lib/active_record/railti
es/databases.rake:379:in `block (4 levels) in <top (required)>'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.2.10/lib/active_record/railti
es/databases.rake:378:in `open'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.2.10/lib/active_record/railti
es/databases.rake:378:in `block (3 levels) in <top (required)>'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/task.rb:228:in `call'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/task.rb:228:in `block i
n execute'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/task.rb:223:in `each'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/task.rb:223:in `execute
'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/task.rb:166:in `block i
n invoke_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-10.0.3/lib/rake/task.rb:159:in `invoke_
with_call_chain'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/task.rb:152:in `invoke'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/application.rb:143:in `
invoke_task'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/application.rb:101:in `
block (2 levels) in top_level'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/application.rb:101:in `
each'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/application.rb:101:in `
block in top_level'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/application.rb:110:in `
run_with_threads'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/application.rb:95:in `t
op_level'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/application.rb:73:in `b
lock in run'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/application.rb:160:in `
standard_exception_handling'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/application.rb:70:in `r
un'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-10.0.3/bin/rake:33:in `<top (required)>
'
C:/Ruby192/bin/rake:19:in `load'
C:/Ruby192/bin/rake:19:in `<main>'
Tasks: TOP => db:schema:dump
C:\Users\ASUS\Desktop\simple_cms>
Now in my database.yml file I have already put user and password in and remembered to put the integerpassword in "" and a space between the colon and the password itself like:
# 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: simple_cms_development
pool: 5
username: simplelogin
password: "1234"
host: localhost
# 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: simple_cms_test
pool: 5
username: root
password:
host: localhost
production:
adapter: mysql2
encoding: utf8
reconnect: false
database: simple_cms_production
pool: 5
username: root
password:
host: localhost
I have even tried switching the "localhost" with the ip as described here (same problem): Rails development - Can't connect to MySQL server on 'localhost' (10061)
But when I do that I don't get any messages in return from the commandline.
So why can't I connect to the database?
Would appreciate any help! Thanks! Trying to learn ruby and the whole installationsprocess has already eaten up lots of hours...
The problem with using the mysql command and using a connector is that mysql can have different default parameters based on how it is configured, making it difficult to know what is going on.
You should look for a file called my.cnf (or my.ini if you're on Windows). It can specify a different port or host. You're lucky that you are able to connect to the database through mysql because you can see where you are actually connected.
Take a look at your port:
mysql> show variables like 'port';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| port | 3306 |
+---------------+-------+
1 row in set (0.00 sec)
mysql> show variables like 'socket';
+---------------+-----------------+
| Variable_name | Value |
+---------------+-----------------+
| socket | /tmp/mysql.sock |
+---------------+-----------------+
1 row in set (0.00 sec)
mysql> show variables like 'hostname';
+---------------+-------------+
| Variable_name | Value |
+---------------+-------------+
| hostname | myhostname |
+---------------+-------------+
1 row in set (0.00 sec)
See if these values match up with the database.yml file.
Once you have these values, you can try to telnet on that port. If there is nothing listening on that port you'll get something like:
$ telnet localhost 11111
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying 127.0.0.1...
telnet: connect to address 127.0.0.1: Connection refused
Trying fe80::1...
telnet: connect to address fe80::1: Connection refused
telnet: Unable to connect to remote host
but if there is a connection, you'll see some junk with "mysql" written somewhere:
$ telnet localhost 3306
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
J
5.5.28JzKEXl7?5e|bUcq/5\Q^mysql_native_passwordConnection closed by foreign host.
I work on Unix, so your output may look different.
I was in the same Lynda course.
development:
adapter: mysql2
encoding: utf8
reconnect: false
database: simple_cms_development
pool: 5
username: root
password:
host: 127.0.0.1
port: 3306
socket: C:/xampp/mysql/mysql.sock
I'm on Windows 8 and using mysql with the XAMPP package.
I have tried everything, and what really fixed it was the change from localhost to 127.0.0.1
I worked on this issue for a few days, tried nearly every solution available on internet.
Finally I am able to solve that error by adding port:3306 and restarting WEBrick server using 'rails server' command.
Thank you.
I have seen this hideous thing in Ruby and in the command line!
Can't connect to MySQL server on 'localhost' (10061)
If the solutions above doesn't work, I suspect it could be a problem related to the lack MySQL services running. Rails cannot access MySQL, unless you solve the bug of MySQL.
DIAGNOSIS
Before trying the solution below, go to the command line and try to access MySQL once again from the bin folder:
mysql -u username -p
If you get something like this:
ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061)
Then try this:
Run the cmd as administrator (if you can't you must consult with your IT representative)
Go to the bin folder in MySQL and install MySQL services using the following command:
mysqld --install
You can receive any of these 2 messages:
The service already exists!
OR
The service was sucessfully installed
Don't close the cmd!
Search for "Services"
Once you've opened "Services" select MySQL and click "start".
From the command line try to access mysql again as unidentified user, as root or as simple_cms.
mysql -u simplelogin -p
If you are successful, then try to run rails again
Related
I've got an Ubuntu virtual server (Digital Ocean Droplet) set up with Capistrano 3. I've successfully gotten all of the directories set up and the project directory has the current folder in it, containing config/database.yml file. I can't get it deployed to where it will run. It gets stuck on the rake db:migrate phase. rake assets:precompile successfully works, so I think it must be something with my database.yml file. The "production" block looks like this:
config/database.yml (production part)
production:
adapter: mysql2
encoding: utf8
database: capstone_production
username: <%= ENV['DATABASE_USERNAME'] %>
password: <%= ENV['DATABASE_PASSWORD'] %>
host: localhost
port: /var/run/mysqld/mysqld.sock
I have checked that the file is valid YAML with YAMLLint utility. Also, the environment variables echo properly with (root) credentials that I am able to use for mysql login. When I run cap production deploy:check, everything is good. However, running cap production deploy does everything okay until it gets to the rake db:migrate Capistrano process. Then it aborts and throws up this:
The deploy has failed with an error: #<SSHKit::Runner::ExecuteError: Exception while executing on host 107.170.105.223: Exception while executing on host 107.170.105.223: rake exit status: 1
rake stdout: rake aborted!
Mysql2::Error: Access denied for user 'root'#'localhost' (using password: NO)
/home/deploy/apps/capstone_project/shared/bundle/ruby/2.1.0/gems/mysql2-0.3.20/lib/mysql2/client.rb:70:in `connect'
/home/deploy/apps/capstone_project/shared/bundle/ruby/2.1.0/gems/mysql2-0.3.20/lib/mysql2/client.rb:70:in `initialize'
/home/deploy/apps/capstone_project/shared/bundle/ruby/2.1.0/bundler/gems/rails-331210df7c8a/activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb:18:in `new'
/home/deploy/apps/capstone_project/shared/bundle/ruby/2.1.0/bundler/gems/rails-331210df7c8a/activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb:18:in `mysql2_connection'
/home/deploy/apps/capstone_project/shared/bundle/ruby/2.1.0/bundler/gems/rails-331210df7c8a/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:435:in `new_connection'
/home/deploy/apps/capstone_project/shared/bundle/ruby/2.1.0/bundler/gems/rails-331210df7c8a/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:445:in `checkout_new_connection'
/home/deploy/apps/capstone_project/shared/bundle/ruby/2.1.0/bundler/gems/rails-331210df7c8a/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:416:in `acquire_connection'
/home/deploy/apps/capstone_project/shared/bundle/ruby/2.1.0/bundler/gems/rails-331210df7c8a/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:351:in `block in checkout'
/home/deploy/apps/capstone_project/shared/bundle/ruby/2.1.0/bundler/gems/rails-331210df7c8a/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:350:in `checkout'
/home/deploy/apps/capstone_project/shared/bundle/ruby/2.1.0/bundler/gems/rails-331210df7c8a/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:265:in `block in connection'
/home/deploy/apps/capstone_project/shared/bundle/ruby/2.1.0/bundler/gems/rails-331210df7c8a/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:264:in `connection'
/home/deploy/apps/capstone_project/shared/bundle/ruby/2.1.0/bundler/gems/rails-331210df7c8a/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:541:in `retrieve_connection'
/home/deploy/apps/capstone_project/shared/bundle/ruby/2.1.0/bundler/gems/rails-331210df7c8a/activerecord/lib/active_record/connection_handling.rb:113:in `retrieve_connection'
/home/deploy/apps/capstone_project/shared/bundle/ruby/2.1.0/bundler/gems/rails-331210df7c8a/activerecord/lib/active_record/connection_handling.rb:87:in `connection'
/home/deploy/apps/capstone_project/shared/bundle/ruby/2.1.0/bundler/gems/rails-331210df7c8a/activerecord/lib/active_record/migration.rb:916:in `initialize'
/home/deploy/apps/capstone_project/shared/bundle/ruby/2.1.0/bundler/gems/rails-331210df7c8a/activerecord/lib/active_record/migration.rb:814:in `new'
/home/deploy/apps/capstone_project/shared/bundle/ruby/2.1.0/bundler/gems/rails-331210df7c8a/activerecord/lib/active_record/migration.rb:814:in `up'
/home/deploy/apps/capstone_project/shared/bundle/ruby/2.1.0/bundler/gems/rails-331210df7c8a/activerecord/lib/active_record/migration.rb:792:in `migrate'
/home/deploy/apps/capstone_project/shared/bundle/ruby/2.1.0/bundler/gems/rails-331210df7c8a/activerecord/lib/active_record/railties/databases.rake:34:in `block (2 levels) in <top (required)>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
rake stderr: Nothing written
I've tried many combinations of YAML syntax and restarted mysql server, puma server, and NGINX server over and over again. This is crazy, please help.
UPDATE
The problem seems to stem from this:
Mysql2::Error: Access denied for user 'root'#'localhost' (using password: NO)
From what I've read in MySQL docs, this error is thrown when you try to login without password. So I've got all the right credentials - I can even hard code the actual username and password into the YAML file and same error. For some reason when Capistrano executes the following command (via cap production deploy or cap production deploy:migrate), it's not including the password from database.yml:
INFO [85893e95] Running ~/.rvm/bin/rvm default do bundle exec rake db:migrate on 107.170.105.223
DEBUG [85893e95] Command: cd /home/deploy/apps/capstone_project/releases/20160205235633 && ( export RAILS_ENV="production" ; ~/.rvm/bin/rvm default do bundle exec rake db:migrate )
How to ensure that Capistrano executes the migration just like I would locally in development?
Thank you
This question already has answers here:
mysql2 gem compiled for wrong mysql client library
(8 answers)
Closed 8 years ago.
I want to run a rails application on my mac osx 10.9.3 and got following error:
/Users/home/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/mysql2-0.3.16/lib/mysql2.rb:8:in `require': Incorrect MySQL client library version! This gem was compiled for 5.5.23 but the client library is 5.6.19. (RuntimeError)
from /Users/home/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/mysql2-0.3.16/lib/mysql2.rb:8:in `<top (required)>'
from /Users/home/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/bundler-1.6.3/lib/bundler/runtime.rb:76:in `require'
from /Users/home/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/bundler-1.6.3/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
from /Users/home/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/bundler-1.6.3/lib/bundler/runtime.rb:72:in `each'
from /Users/home/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/bundler-1.6.3/lib/bundler/runtime.rb:72:in `block in require'
from /Users/home/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/bundler-1.6.3/lib/bundler/runtime.rb:61:in `each'
from /Users/home/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/bundler-1.6.3/lib/bundler/runtime.rb:61:in `require'
from /Users/home/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/bundler-1.6.3/lib/bundler.rb:132:in `require'
from /Users/home/workSpace/RubyOnRails/simple_cms/config/application.rb:7:in `<top (required)>'
from /Users/home/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/railties-4.1.1/lib/rails/commands/commands_tasks.rb:79:in `require'
from /Users/home/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/railties-4.1.1/lib/rails/commands/commands_tasks.rb:79:in `block in server'
from /Users/home/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/railties-4.1.1/lib/rails/commands/commands_tasks.rb:76:in `tap'
from /Users/home/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/railties-4.1.1/lib/rails/commands/commands_tasks.rb:76:in `server'
from /Users/home/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/railties-4.1.1/lib/rails/commands/commands_tasks.rb:40:in `run_command!'
from /Users/home/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/railties-4.1.1/lib/rails/commands.rb:17:in `<top (required)>'
from bin/rails:8:in `require'
from bin/rails:8:in `<main>'
I installed mysql with hombrew and it's working perfectly. I also use rbenv.
gem 'rails', '4.1.1'
gem 'mysql2'
and this is my databas.yml file
development:
adapter: mysql2
encoding: utf8
database: simple_cms_development
pool: 5
username: root
password: somepassword
socket: /tmp/mysql.sock
test:
adapter: mysql2
encoding: utf8
database: simple_cms_test
pool: 5
username: root
password: somepassword
socket: /tmp/mysql.sock
production:
adapter: mysql2
encoding: utf8
database: simple_cms_production
pool: 5
username: root
password: somepassword
socket: /tmp/mysql.sock
How can I solve it?
Headers
I was going to suggest using mysql C-connector (the recommended answer in the comments confirmed this)
We've written a tutorial on how to do this (for the typical unable to build native extensions error), but same idea
--
C-Connector
Basically, your gem just needs to interface with your system; it doesn't need need to do anything buy send queries & process the responses to your db
This means if you have a problem with your mysql version's compatibility, you'll be best installing & using a separate batch of header files (for your gem):
The way to do this is to download & install the mysql c-connector
files - IMPORTANT - GET THE 32 BIT VERSION (you can either use
the installer or unzip the files)
Once installed, you should install the gem with the following command:
gem install mysql2 --platform=ruby -- ‘--with-mysql-dir="YOUR_MYSQL_DIR”’
This should install the gem for you, which will allow you to interface with the MYSQL server
we are trying to integrate an existing mysql database in our jruby on rails application.
Our client provided us with a bare bone rails skeleton, which was not configured for a sepcific database. We were later provided with a sql database and were asked to integerate it in our application using mysql. We started out by creating a database.yml file with the necessairy information. We then executed the rake db:create command, which resulted in following error message below. Any suggestions on what we're doing wrong? We're helpless. Thx in advance.
$ rake db:create --trace
rake aborted!
undefined method `each' for nil:NilClass
/Users/rath_rio/.rvm/gems/jruby-1.6.6#webgrouper/gems/activerecord-jdbc-adapter-1.2.2/lib/arjdbc/jdbc/jdbc.rake:15:in `redefine_task'
/Users/rath_rio/.rvm/gems/jruby-1.6.6#webgrouper/gems/activerecord-jdbc-adapter-1.2.2/lib/arjdbc/jdbc/jdbc.rake:23:in `(root)'
/Users/rath_rio/.rvm/gems/jruby-1.6.6#webgrouper/gems/rake-0.9.2.2/lib/rake/task_manager.rb:207:in `in_namespace'
/Users/rath_rio/.rvm/gems/jruby-1.6.6#webgrouper/gems/rake-0.9.2.2/lib/rake/dsl_definition.rb:102:in `namespace'
/Users/rath_rio/.rvm/gems/jruby-1.6.6#webgrouper/gems/activerecord-jdbc-adapter-1.2.2/lib/arjdbc/jdbc/jdbc.rake:22:in `(root)'
org/jruby/RubyKernel.java:1052:in `load'
/Users/rath_rio/.rvm/gems/jruby-1.6.6#webgrouper/gems/activerecord-jdbc-adapter-1.2.2/lib/arjdbc/jdbc/jdbc.rake:234:in `load'
/Users/rath_rio/.rvm/gems/jruby-1.6.6#webgrouper/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:223:in `load_dependency'
/Users/rath_rio/.rvm/gems/jruby-1.6.6#webgrouper/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:640:in `new_constants_in'
/Users/rath_rio/.rvm/gems/jruby-1.6.6#webgrouper/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:639:in `new_constants_in'
/Users/rath_rio/.rvm/gems/jruby-1.6.6#webgrouper/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:223:in `load_dependency'
/Users/rath_rio/.rvm/gems/jruby-1.6.6#webgrouper/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:234:in `load'
/Users/rath_rio/.rvm/gems/jruby-1.6.6#webgrouper/gems/rake-0.9.2.2/lib/rake/rake_module.rb:25:in `load_rakefile'
/Users/rath_rio/.rvm/gems/jruby-1.6.6#webgrouper/gems/rake-0.9.2.2/lib/rake/default_loader.rb:6:in `load'
/Users/rath_rio/.rvm/gems/jruby-1.6.6#webgrouper/gems/rake-0.9.2.2/lib/rake/application.rb:569:in `load_imports'
/Users/rath_rio/.rvm/gems/jruby-1.6.6#webgrouper/gems/rake-0.9.2.2/lib/rake/application.rb:508:in `raw_load_rakefile'
/Users/rath_rio/.rvm/gems/jruby-1.6.6#webgrouper/gems/rake-0.9.2.2/lib/rake/application.rb:82:in `load_rakefile'
/Users/rath_rio/.rvm/gems/jruby-1.6.6#webgrouper/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/Users/rath_rio/.rvm/gems/jruby-1.6.6#webgrouper/gems/rake-0.9.2.2/lib/rake/application.rb:81:in `load_rakefile'
/Users/rath_rio/.rvm/gems/jruby-1.6.6#webgrouper/gems/rake-0.9.2.2/lib/rake/application.rb:65:in `run'
/Users/rath_rio/.rvm/gems/jruby-1.6.6#webgrouper/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/Users/rath_rio/.rvm/gems/jruby-1.6.6#webgrouper/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
/Users/rath_rio/.rvm/gems/jruby-1.6.6#webgrouper/gems/rake-0.9.2.2/bin/rake:33:in `(root)'
org/jruby/RubyKernel.java:1052:in `load'
/Users/rath_rio/.rvm/gems/jruby-1.6.6#webgrouper/bin/rake:19:in `(root)'
our system specification:
Java SE 6
JRuby 1.6.6
Rails 3.1
we use following gems for our datebase:
gem 'mysql2', '~>0.3.0'
gem "jdbc-mysql", "~> 5.1.13"
gem "activerecord-jdbc-adapter", "~> 1.2.2"
gem "activerecord-jdbcmysql-adapter", "~> 1.2.2"
our database.yml file:
development:
database: webgrouper_development
adapter: jdbcmysql
encoding: utf8
reconnect: true
pool: 5
username: root
password:
host: 127.0.0.1
test:
database: webgrouper_test
adapter: jdbcmysql
encoding: utf8
reconnect: false
pool: 5
username: root
password:
host: 127.0.0.1
production:
database: webgrouper_production
adapter: jdbcmysql
encoding: utf8
reconnect: false
pool: 5
username: root
password:
host: 127.0.0.1
What I can say so far, having run across this while troubleshooting something else and happening to have the relevant source code up, is that this rake task is dying because it is attempting to iterate over the actions for the current task, but the set of actions is nil.
Understanding exactly what was done wrong in the terse and uncommented code in there is difficult. Something is making this incredibly fragile system break down. I have an odd wild guess. What happens if you put "adapter: jdbcmysql" as the first part of each database stanza in your YML, instead of "database: webgrouper_production"?
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
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.