MySql2 on Rails 3.0.3 on Mac OS X - mysql

I know this has been asked many times by different other users with similar problem, but I can't seems to find one that are similar to my case:
My specs:
OS - Mac OSX 10.6 Snowleopard
SQL Server - MySQL 5.5
Rails - 3.0.3
Ruby 1.8.7
While try to run a rake db:create, I run into the following error message:
"uninitialized constant Mysql2"
Full trace is posted if you are interested:-
** Invoke db:create (first_time)
** Invoke db:load_config (first_time)
** Invoke rails_env (first_time)
** Execute rails_env
** Execute db:load_config
** Execute db:create
rake aborted!
uninitialized constant Mysql2
/Library/Ruby/Gems/1.8/gems/activerecord-3.0.3/lib/active_record/railties/databases.rake:64:in `create_database'
/Library/Ruby/Gems/1.8/gems/activerecord-3.0.3/lib/active_record/railties/databases.rake:33
/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: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

Same configuration, same problem here...
Edit: Solved! Had to add gem 'mysql2' to the Gemfile and run bundle install. Now it works fine.

Try:
sudo gem install mysql2
bundle install

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

Heroku rake db:structure:load with cleardb can't find 'mysql'

I am trying to install an instance of Sharetribe on a heroku dyno. I am at the point where I am trying to create the database. I first tried rake db:migrate and it worked for most of the migrations but failed on one of them.
I was advised to use rake db:structure:load, so I tried that and I am getting an error from Heroku saying that mysql needs to be added to the PATH variable. Why is this, and how can I fix it? I'm not sure why it happens on db:schema:load and db:structure:load but not on db:migrate.
The complete stack trace with the error message is:
rake aborted!
failed to execute:
mysqlPlease check the output above for any errors and make sure that `mysql` is installed in your PATH and has proper permissions.
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/tasks/mysql_database_tasks.rb:148:in `run_cmd'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/tasks/mysql_database_tasks.rb:72:in `structure_load'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/tasks/database_tasks.rb:189:in `structure_load'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/tasks/database_tasks.rb:222:in `load_schema_for'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/tasks/database_tasks.rb:236:in `block in load_schema_current'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/tasks/database_tasks.rb:276:in `block in each_current_configuration'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/tasks/database_tasks.rb:275:in `each'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/tasks/database_tasks.rb:275:in `each_current_configuration'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/tasks/database_tasks.rb:235:in `load_schema_current'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/railties/databases.rake:293:in `block (3 levels) in <top (required)>'
/app/vendor/bundle/ruby/2.3.0/gems/bundler-1.13.7/lib/bundler/cli/exec.rb:74:in `load'
/app/vendor/bundle/ruby/2.3.0/gems/bundler-1.13.7/lib/bundler/cli/exec.rb:74:in `kernel_load'
/app/vendor/bundle/ruby/2.3.0/gems/bundler-1.13.7/lib/bundler/cli/exec.rb:27:in `run'
/app/vendor/bundle/ruby/2.3.0/gems/bundler-1.13.7/lib/bundler/cli.rb:332:in `exec'
/app/vendor/bundle/ruby/2.3.0/gems/bundler-1.13.7/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/app/vendor/bundle/ruby/2.3.0/gems/bundler-1.13.7/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
/app/vendor/bundle/ruby/2.3.0/gems/bundler-1.13.7/lib/bundler/vendor/thor/lib/thor.rb:359:in `dispatch'
/app/vendor/bundle/ruby/2.3.0/gems/bundler-1.13.7/lib/bundler/cli.rb:20:in `dispatch'
/app/vendor/bundle/ruby/2.3.0/gems/bundler-1.13.7/lib/bundler/vendor/thor/lib/thor/base.rb:440:in `start'
/app/vendor/bundle/ruby/2.3.0/gems/bundler-1.13.7/lib/bundler/cli.rb:11:in `start'
/app/vendor/bundle/ruby/2.3.0/gems/bundler-1.13.7/exe/bundle:34:in `block in <top (required)>'
/app/vendor/bundle/ruby/2.3.0/gems/bundler-1.13.7/lib/bundler/friendly_errors.rb:100:in `with_friendly_errors'
/app/vendor/bundle/ruby/2.3.0/gems/bundler-1.13.7/exe/bundle:26:in `<top (required)>'
/app/bin/bundle:3:in `load'
/app/bin/bundle:3:in `<main>'
Tasks: TOP => db:structure:load
(See full trace by running task with --trace)
Thanks!
If you need to run heroku run bundle exec rake db:structure:load than you need to install mysql client.
To install additional packages you need to add Buildpacks (official or community based).
For mysql I successfully used https://github.com/din-co/heroku-buildpack-mysql
heroku buildpacks:add --index 1 https://github.com/din-co/heroku-buildpack-mysql
git commit --amend --allow-empty --no-edit
git push heroku -f
Heroku doesn't support mysql, you need to use pg gem in your gemfile in production block.
Please read Getting Started with Rails 5.x on Heroku

Error on connecting MySQL with Ruby on Rails

I have just setup the MySQL with Ruby on Rails. I have created a new rails project giving following command
rails new test1 –d mysql
The project got successfully created but I am getting error when I give below command
rake db:create
The error is
C:\Users\HP\test1>rake db:create
rake aborted!
(<unknown>): did not find expected key while parsing a block mapping at line 11
column 1
Tasks: TOP => db:create => db:load_config
(See full trace by running task with --trace)
Got below messages when I ran trace command
C:\Users\HP\test1>rake db:create --trace
** Invoke db:create (first_time)
** Invoke db:load_config (first_time)
** Invoke rails_env (first_time)
** Execute rails_env
** Execute db:load_config
rake aborted!
(<unknown>): did not find expected key while parsing a block mapping at line 11
column 1
C:/Ruby200/lib/ruby/2.0.0/psych.rb:205:in `parse'
C:/Ruby200/lib/ruby/2.0.0/psych.rb:205:in `parse_stream'
C:/Ruby200/lib/ruby/2.0.0/psych.rb:153:in `parse'
C:/Ruby200/lib/ruby/2.0.0/psych.rb:129:in `load'
C:/Ruby200/lib/ruby/gems/2.0.0/gems/railties-3.1.1/lib/rails/application/configu
ration.rb:106:in `database_configuration'
C:/Ruby200/lib/ruby/gems/2.0.0/gems/activerecord-3.1.1/lib/active_record/railtie
s/databases.rake:6:in `block (2 levels) in <top (required)>'
C:/Ruby200/lib/ruby/gems/2.0.0/gems/rake-10.1.0/lib/rake/task.rb:236:in `call'
C:/Ruby200/lib/ruby/gems/2.0.0/gems/rake-10.1.0/lib/rake/task.rb:236:in `block i
n execute'
C:/Ruby200/lib/ruby/gems/2.0.0/gems/rake-10.1.0/lib/rake/task.rb:231:in `each'
C:/Ruby200/lib/ruby/gems/2.0.0/gems/rake-10.1.0/lib/rake/task.rb:231:in `execute
'
C:/Ruby200/lib/ruby/gems/2.0.0/gems/rake-10.1.0/lib/rake/task.rb:175:in `block i
n invoke_with_call_chain'
C:/Ruby200/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
C:/Ruby200/lib/ruby/gems/2.0.0/gems/rake-10.1.0/lib/rake/task.rb:168:in `invoke_
with_call_chain'
C:/Ruby200/lib/ruby/gems/2.0.0/gems/rake-10.1.0/lib/rake/task.rb:197:in `block i
n invoke_prerequisites'
C:/Ruby200/lib/ruby/gems/2.0.0/gems/rake-10.1.0/lib/rake/task.rb:195:in `each'
C:/Ruby200/lib/ruby/gems/2.0.0/gems/rake-10.1.0/lib/rake/task.rb:195:in `invoke_
prerequisites'
C:/Ruby200/lib/ruby/gems/2.0.0/gems/rake-10.1.0/lib/rake/task.rb:174:in `block i
n invoke_with_call_chain'
C:/Ruby200/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
C:/Ruby200/lib/ruby/gems/2.0.0/gems/rake-10.1.0/lib/rake/task.rb:168:in `invoke_
with_call_chain'
C:/Ruby200/lib/ruby/gems/2.0.0/gems/rake-10.1.0/lib/rake/task.rb:161:in `invoke'
C:/Ruby200/lib/ruby/gems/2.0.0/gems/rake-10.1.0/lib/rake/application.rb:149:in `
invoke_task'
C:/Ruby200/lib/ruby/gems/2.0.0/gems/rake-10.1.0/lib/rake/application.rb:106:in `
block (2 levels) in top_level'
C:/Ruby200/lib/ruby/gems/2.0.0/gems/rake-10.1.0/lib/rake/application.rb:106:in `
each'
C:/Ruby200/lib/ruby/gems/2.0.0/gems/rake-10.1.0/lib/rake/application.rb:106:in `
block in top_level'
C:/Ruby200/lib/ruby/gems/2.0.0/gems/rake-10.1.0/lib/rake/application.rb:115:in `
run_with_threads'
C:/Ruby200/lib/ruby/gems/2.0.0/gems/rake-10.1.0/lib/rake/application.rb:100:in `
top_level'
C:/Ruby200/lib/ruby/gems/2.0.0/gems/rake-10.1.0/lib/rake/application.rb:78:in `b
lock in run'
C:/Ruby200/lib/ruby/gems/2.0.0/gems/rake-10.1.0/lib/rake/application.rb:165:in `
standard_exception_handling'
C:/Ruby200/lib/ruby/gems/2.0.0/gems/rake-10.1.0/lib/rake/application.rb:75:in `r
un'
C:/Ruby200/lib/ruby/gems/2.0.0/gems/rake-10.1.0/bin/rake:33:in `<top (required)>
'
C:/Ruby200/bin/rake:23:in `load'
C:/Ruby200/bin/rake:23:in `<main>'
Tasks: TOP => db:create => db:load_config
Not sure which file to look for error:
(<unknown>): did not find expected key while parsing a block mapping at line 11
column 1
I am struggling for last few hours to resolve this but couldn't find a solution. Please advise. Thanks.
I was giving the root password by opening the yml file in plain notepad. So I believe it was unable to read the password. I then edited yml file through notepad++ and it worked fine. So seems like we need to use either notepad++ or editplus or some similar toll to edit these files.
It looks like your config\database.yml file is missing some data, it should look something like the following:
development:
adapter: mysql
database: my_project_development
host: localhost
username: my_user
password: my_password
You will also need a mysql gem in your gemfile.

Rails 3.2.2 mysql2 adapter Error

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

mysql + ruby = nightmare

Ok, I'm done.
I can't understand why I got this error with:
rake features
It cant' be I can't connect to mysql cause the:
rake db:migrate
works perfectly.
I keep having this error:
rake features --trace
(in /Users/myname/Projects/rails_app)
** Invoke features (first_time)
** Invoke db:test:prepare (first_time)
** Invoke db:abort_if_pending_migrations (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:abort_if_pending_migrations
** Execute db:test:prepare
** Invoke db:test:load (first_time)
** Invoke db:test:purge (first_time)
** Invoke environment
** Execute db:test:purge
** Execute db:test:load
** Invoke db:schema:load (first_time)
** Invoke environment
** Execute db:schema:load
rake aborted!
closed stream
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/mysql.rb:1032:in `sync='
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/mysql.rb:1032:in `write'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/mysql.rb:1092:in `finalizer'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/mysql.rb:578:in `call'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/mysql.rb:578:in `start'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/mysql.rb:578:in `free'
/Users/myname/Projects/rails_app/vendor/rails/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb:438:in `tables'
/Users/myname/Projects/rails_app/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb:24:in `table_exists?'
/Users/myname/Projects/rails_app/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb:106:in `create_table'
/Users/myname/Projects/rails_app/vendor/rails/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb:473:in `create_table'
/Users/myname/Projects/rails_app/vendor/rails/activerecord/lib/active_record/migration.rb:352:in `send'
/Users/myname/Projects/rails_app/vendor/rails/activerecord/lib/active_record/migration.rb:352:in `method_missing'
/Users/myname/Projects/rails_app/vendor/rails/activerecord/lib/active_record/migration.rb:328:in `say_with_time'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/benchmark.rb:293:in `measure'
/Users/myname/Projects/rails_app/vendor/rails/activerecord/lib/active_record/migration.rb:328:in `say_with_time'
/Users/myname/Projects/rails_app/vendor/rails/activerecord/lib/active_record/migration.rb:348:in `method_missing'
/Users/myname/Projects/rails_app/db/schema.rb:38
/Users/myname/Projects/rails_app/vendor/rails/activerecord/lib/active_record/schema.rb:43:in `instance_eval'
/Users/myname/Projects/rails_app/vendor/rails/activerecord/lib/active_record/schema.rb:43:in `define'
/Users/myname/Projects/rails_app/db/schema.rb:12
/Users/myname/Projects/rails_app/vendor/rails/activesupport/lib/active_support/dependencies.rb:145:in `load_without_new_constant_marking'
/Users/myname/Projects/rails_app/vendor/rails/activesupport/lib/active_support/dependencies.rb:145:in `load'
/Users/myname/Projects/rails_app/vendor/rails/activesupport/lib/active_support/dependencies.rb:521:in `new_constants_in'
/Users/myname/Projects/rails_app/vendor/rails/activesupport/lib/active_support/dependencies.rb:145:in `load'
/Users/myname/Projects/rails_app/vendor/rails/railties/lib/tasks/databases.rake:259
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `call'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `execute'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `each'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `execute'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:597:in `invoke_with_call_chain'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:583:in `invoke'
/Users/myname/Projects/rails_app/vendor/rails/railties/lib/tasks/databases.rake:304
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `call'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `execute'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `each'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `execute'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:597:in `invoke_with_call_chain'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:583:in `invoke'
/Users/myname/Projects/rails_app/vendor/rails/railties/lib/tasks/databases.rake:378
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `call'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `execute'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `each'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `execute'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:597:in `invoke_with_call_chain'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:607:in `invoke_prerequisites'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:604:in `each'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:604:in `invoke_prerequisites'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:596:in `invoke_with_call_chain'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:583:in `invoke'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:2051:in `invoke_task'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `each'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:2023:in `top_level'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:2001:in `run'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:1998:in `run'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/bin/rake:31
/usr/bin/rake:19:in `load'
/usr/bin/rake:19
My machine:
Mac OS X 10.5.8
ruby 1.8.6 (2008-08-11 patchlevel 287) [universal-darwin9.0]
Rails 2.3.4
mysql (2.8.1) [rubygem]
Mysql path: /opt/local/lib/mysql5 [installed via macport]
Thank you so much!
Save your DBs and reinstall mysql. Follow http://hivelogic.com/articles/compiling-mysql-on-snow-leopard/ Made all my problems go away.
I have to theories about your problem, but no reason to suspect either is really your cause, but they're quick checks.
You haven't properly defined the testing database in config/databases.yml
The mysql user that is attempting to build this database lacks the permission to do so.
Can you connect to the database in question with the credentials in question (all the stuff in database.yml)?
"mysql -u your_user -p" from the command line?
When you installed the mysql gem did it properly build the native extensions?
What happens when you gem install mysql --force (to re-install it)? Does it look happy?
Have you ever done this before? Is the problem as likely to be a lack of experience with rails/mysql or both? Or is this old hat and you just can't figure it out this time?
If the former, the tutorial in the pragramatic agile web development with rails is quite good (as is the rest of the book).
Hope something there helps.
Please tell the output of:
rake db:schema:load RAILS_ENV=test
to be sure that an existing database named _test is configured and working under config/database.yml