Ruby Gem LoadError mysql2/mysql2 required - mysql

Im trying to setup my rails server on OSX 10.8 but I can't get my rails server to run.
- Currently Im using a Zend Server with mysql 5.1.
- I also have istalled brew and brew mysql.
- And I used: gem install mysql2 -- --srcdir=/usr/local/mysql/include --with-opt-include=/usr/local/mysql/include
the server worked already but now, I always get this loadError below.
This is what my Gemfile says:
ralphs-macbook-pro:admin-mockup zero$ bundle install
Using rake (10.0.2)
Using i18n (0.6.1)
Using multi_json (1.3.7)
Using activesupport (3.2.7)
Using builder (3.0.4)
Using activemodel (3.2.7)
Using erubis (2.7.0)
Using journey (1.0.4)
Using rack (1.4.1)
Using rack-cache (1.2)
Using rack-test (0.6.2)
Using hike (1.2.1)
Using tilt (1.3.3)
Using sprockets (2.1.3)
Using actionpack (3.2.7)
Using mime-types (1.19)
Using polyglot (0.3.3)
Using treetop (1.4.12)
Using mail (2.4.4)
Using actionmailer (3.2.7)
Using arel (3.0.2)
Using tzinfo (0.3.35)
Using activerecord (3.2.7)
Using activeresource (3.2.7)
Using annotate (2.5.0)
Using coffee-script-source (1.4.0)
Using execjs (1.4.0)
Using coffee-script (2.2.0)
Using rack-ssl (1.3.2)
Using json (1.7.5)
Using rdoc (3.12)
Using thor (0.16.0)
Using railties (3.2.7)
Using coffee-rails (3.2.2)
Using columnize (0.3.6)
Using debugger-ruby_core_source (1.1.5)
Using debugger-linecache (1.1.2)
Using debugger (1.2.2)
Using formtastic (2.2.1)
Using haml (3.1.7)
Using haml-rails (0.3.5)
Using hirb (0.7.0)
Using hpricot (0.8.6)
Using jquery-rails (2.1.4)
Using kgio (2.7.4)
Using mysql2 (0.3.11)
Using php_serialize (1.2)
Using polyamorous (0.5.0)
Using rabl (0.7.8)
Using railroady (1.1.0)
Using bundler (1.2.3)
Using rails (3.2.7)
Using raindrops (0.10.0)
Using randumb (0.3.0)
Using sass (3.2.3)
Using sass-rails (3.2.5)
Using squeel (1.0.13)
Using uglifier (1.3.0)
Using unicorn (4.4.0)
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled
gem is installed.
And after starting rails s
/Users/zero/.rvm/gems/ruby-1.9.3-p327/gems/mysql2-0.3.11/lib/mysql2.rb:9:in `require': cannot load such file -- mysql2/mysql2 (LoadError)
from /Users/zero/.rvm/gems/ruby-1.9.3-p327/gems/mysql2-0.3.11/lib/mysql2.rb:9:in `<top (required)>'
from /Users/zero/.rvm/gems/ruby-1.9.3-p327/gems/bundler-1.2.3/lib/bundler/runtime.rb:68:in `require'
from /Users/zero/.rvm/gems/ruby-1.9.3-p327/gems/bundler-1.2.3/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
from /Users/zero/.rvm/gems/ruby-1.9.3-p327/gems/bundler-1.2.3/lib/bundler/runtime.rb:66:in `each'
from /Users/zero/.rvm/gems/ruby-1.9.3-p327/gems/bundler-1.2.3/lib/bundler/runtime.rb:66:in `block in require'
from /Users/zero/.rvm/gems/ruby-1.9.3-p327/gems/bundler-1.2.3/lib/bundler/runtime.rb:55:in `each'
from /Users/zero/.rvm/gems/ruby-1.9.3-p327/gems/bundler-1.2.3/lib/bundler/runtime.rb:55:in `require'
from /Users/zero/.rvm/gems/ruby-1.9.3-p327/gems/bundler-1.2.3/lib/bundler.rb:128:in `require'
from /Users/zero/GitHub/admin-mockup/config/application.rb:7:in `<top (required)>'
from /Users/zero/.rvm/gems/ruby-1.9.3-p327/gems/railties-3.2.7/lib/rails/commands.rb:53:in `require'
from /Users/zero/.rvm/gems/ruby-1.9.3-p327/gems/railties-3.2.7/lib/rails/commands.rb:53:in `block in <top (required)>'
from /Users/zero/.rvm/gems/ruby-1.9.3-p327/gems/railties-3.2.7/lib/rails/commands.rb:50:in `tap'
from /Users/zero/.rvm/gems/ruby-1.9.3-p327/gems/railties-3.2.7/lib/rails/commands.rb:50:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
Thx for any help!

Check for this solutions:
http://railsforum.com/viewtopic.php?id=50501
rake db:migrate giving error for mysql2

after that I changed my database.yml as follows:
development:
adapter: mysql2
socket: /usr/local/zend/mysql/tmp/mysql.sock
#host: 127.0.0.1
so that I used my local zend MySQL socket.
In my case the ""Can't connect to MySQL server on '127.0.0.1' (61) (Mysql2::Error)" was gone.
Thx #dinnouti for the usefull links above.

Related

Ruby on Rails cannot connect to mysql database

I have mysql installed via homebrew. Created the database prestamoApp_development I started the server (mysql.server start) and then created a new empty project (rails new prestamoApp -d mysql).
Finally configured the user and password in the database.yml file like this:
default: &default
adapter: mysql2
encoding: utf8
pool: 5
username: root
password: pqdsimple
socket: /tmp/mysql.sock
development:
<<: *default
database: prestamoApp_development
# 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: prestamoApp_test
# As with config/secrets.yml, you never want to store sensitive information,
# like your database password, in your source code. If your source code is
# ever seen by anyone, they now have access to your database.
#
# Instead, provide the password as a unix environment variable when you boot
# the app. Read http://guides.rubyonrails.org/configuring.html#configuring-a-database
# for a full rundown on how to provide these environment variables in a
# production deployment.
#
# On Heroku and other platform providers, you may have a full connection URL
# available as an environment variable. For example:
#
# DATABASE_URL="mysql2://myuser:mypass#localhost/somedatabase"
#
# You can use this database configuration with:
#
# production:
# url: <%= ENV['DATABASE_URL'] %>
#
production:
<<: *default
database: prestamoApp_production
username: prestamoApp
password: <%= ENV['PRESTAMOAPP_DATABASE_PASSWORD'] %>
this is the gem file:
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.4'
# Use mysql as the database for Active Record
gem 'mysql2'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use Unicorn as the app server
# gem 'unicorn'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug'
end
group :development do
# Access an IRB console on exception pages or by using <%= console %> in views
gem 'web-console', '~> 2.0'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
end
and just in case the gem file.lock:
GEM
remote: https://rubygems.org/
specs:
actionmailer (4.2.4)
actionpack (= 4.2.4)
actionview (= 4.2.4)
activejob (= 4.2.4)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 1.0, >= 1.0.5)
actionpack (4.2.4)
actionview (= 4.2.4)
activesupport (= 4.2.4)
rack (~> 1.6)
rack-test (~> 0.6.2)
rails-dom-testing (~> 1.0, >= 1.0.5)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (4.2.4)
activesupport (= 4.2.4)
builder (~> 3.1)
erubis (~> 2.7.0)
rails-dom-testing (~> 1.0, >= 1.0.5)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
activejob (4.2.4)
activesupport (= 4.2.4)
globalid (>= 0.3.0)
activemodel (4.2.4)
activesupport (= 4.2.4)
builder (~> 3.1)
activerecord (4.2.4)
activemodel (= 4.2.4)
activesupport (= 4.2.4)
arel (~> 6.0)
activesupport (4.2.4)
i18n (~> 0.7)
json (~> 1.7, >= 1.7.7)
minitest (~> 5.1)
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
arel (6.0.3)
binding_of_caller (0.7.2)
debug_inspector (>= 0.0.1)
builder (3.2.2)
byebug (6.0.2)
coffee-rails (4.1.0)
coffee-script (>= 2.2.0)
railties (>= 4.0.0, < 5.0)
coffee-script (2.4.1)
coffee-script-source
execjs
coffee-script-source (1.9.1.1)
debug_inspector (0.0.2)
erubis (2.7.0)
execjs (2.6.0)
globalid (0.3.6)
activesupport (>= 4.1.0)
i18n (0.7.0)
jbuilder (2.3.1)
activesupport (>= 3.0.0, < 5)
multi_json (~> 1.2)
jquery-rails (4.0.5)
rails-dom-testing (~> 1.0)
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
json (1.8.3)
loofah (2.0.3)
nokogiri (>= 1.5.9)
mail (2.6.3)
mime-types (>= 1.16, < 3)
mime-types (2.6.1)
mini_portile (0.6.2)
minitest (5.8.0)
multi_json (1.11.2)
mysql2 (0.4.0)
nokogiri (1.6.6.2)
mini_portile (~> 0.6.0)
rack (1.6.4)
rack-test (0.6.3)
rack (>= 1.0)
rails (4.2.4)
actionmailer (= 4.2.4)
actionpack (= 4.2.4)
actionview (= 4.2.4)
activejob (= 4.2.4)
activemodel (= 4.2.4)
activerecord (= 4.2.4)
activesupport (= 4.2.4)
bundler (>= 1.3.0, < 2.0)
railties (= 4.2.4)
sprockets-rails
rails-deprecated_sanitizer (1.0.3)
activesupport (>= 4.2.0.alpha)
rails-dom-testing (1.0.7)
activesupport (>= 4.2.0.beta, < 5.0)
nokogiri (~> 1.6.0)
rails-deprecated_sanitizer (>= 1.0.1)
rails-html-sanitizer (1.0.2)
loofah (~> 2.0)
railties (4.2.4)
actionpack (= 4.2.4)
activesupport (= 4.2.4)
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rake (10.4.2)
rdoc (4.2.0)
sass (3.4.18)
sass-rails (5.0.4)
railties (>= 4.0.0, < 5.0)
sass (~> 3.1)
sprockets (>= 2.8, < 4.0)
sprockets-rails (>= 2.0, < 4.0)
tilt (>= 1.1, < 3)
sdoc (0.4.1)
json (~> 1.7, >= 1.7.7)
rdoc (~> 4.0)
spring (1.3.6)
sprockets (3.3.4)
rack (~> 1.0)
sprockets-rails (2.3.3)
actionpack (>= 3.0)
activesupport (>= 3.0)
sprockets (>= 2.8, < 4.0)
thor (0.19.1)
thread_safe (0.3.5)
tilt (2.0.1)
turbolinks (2.5.3)
coffee-rails
tzinfo (1.2.2)
thread_safe (~> 0.1)
uglifier (2.7.2)
execjs (>= 0.3.0)
json (>= 1.8.0)
web-console (2.2.1)
activemodel (>= 4.0)
binding_of_caller (>= 0.7.2)
railties (>= 4.0)
sprockets-rails (>= 2.0, < 4.0)
PLATFORMS
ruby
DEPENDENCIES
byebug
coffee-rails (~> 4.1.0)
jbuilder (~> 2.0)
jquery-rails
mysql2
rails (= 4.2.4)
sass-rails (~> 5.0)
sdoc (~> 0.4.0)
spring
turbolinks
uglifier (>= 1.3.0)
web-console (~> 2.0)
BUNDLED WITH
1.10.6
When I try to do this:
rake db:schema:dump
I get this error:
rake aborted!
Gem::LoadError: Specified 'mysql2' for database adapter, but the gem is not loaded. Add `gem 'mysql2'` to your Gemfile (and ensure its version is at the minimum required by ActiveRecord).
/usr/local/lib/ruby/gems/2.2.0/gems/activerecord-4.2.4/lib/active_record/connection_adapters/connection_specification.rb:177:in `rescue in spec'
/usr/local/lib/ruby/gems/2.2.0/gems/activerecord-4.2.4/lib/active_record/connection_adapters/connection_specification.rb:174:in `spec'
/usr/local/lib/ruby/gems/2.2.0/gems/activerecord-4.2.4/lib/active_record/connection_handling.rb:50:in `establish_connection'
/usr/local/lib/ruby/gems/2.2.0/gems/activerecord-4.2.4/lib/active_record/railtie.rb:120:in `block (2 levels) in <class:Railtie>'
/usr/local/lib/ruby/gems/2.2.0/gems/activesupport-4.2.4/lib/active_support/lazy_load_hooks.rb:38:in `instance_eval'
/usr/local/lib/ruby/gems/2.2.0/gems/activesupport-4.2.4/lib/active_support/lazy_load_hooks.rb:38:in `execute_hook'
/usr/local/lib/ruby/gems/2.2.0/gems/activesupport-4.2.4/lib/active_support/lazy_load_hooks.rb:45:in `block in run_load_hooks'
/usr/local/lib/ruby/gems/2.2.0/gems/activesupport-4.2.4/lib/active_support/lazy_load_hooks.rb:44:in `each'
/usr/local/lib/ruby/gems/2.2.0/gems/activesupport-4.2.4/lib/active_support/lazy_load_hooks.rb:44:in `run_load_hooks'
/usr/local/lib/ruby/gems/2.2.0/gems/activerecord-4.2.4/lib/active_record/base.rb:315:in `<module:ActiveRecord>'
/usr/local/lib/ruby/gems/2.2.0/gems/activerecord-4.2.4/lib/active_record/base.rb:26:in `<top (required)>'
/usr/local/lib/ruby/gems/2.2.0/gems/activerecord-4.2.4/lib/active_record/tasks/mysql_database_tasks.rb:8:in `<class:MySQLDatabaseTasks>'
/usr/local/lib/ruby/gems/2.2.0/gems/activerecord-4.2.4/lib/active_record/tasks/mysql_database_tasks.rb:3:in `<module:Tasks>'
/usr/local/lib/ruby/gems/2.2.0/gems/activerecord-4.2.4/lib/active_record/tasks/mysql_database_tasks.rb:2:in `<module:ActiveRecord>'
/usr/local/lib/ruby/gems/2.2.0/gems/activerecord-4.2.4/lib/active_record/tasks/mysql_database_tasks.rb:1:in `<top (required)>'
/usr/local/lib/ruby/gems/2.2.0/gems/activerecord-4.2.4/lib/active_record/tasks/database_tasks.rb:50:in `<module:DatabaseTasks>'
/usr/local/lib/ruby/gems/2.2.0/gems/activerecord-4.2.4/lib/active_record/tasks/database_tasks.rb:37:in `<module:Tasks>'
/usr/local/lib/ruby/gems/2.2.0/gems/activerecord-4.2.4/lib/active_record/tasks/database_tasks.rb:4:in `<module:ActiveRecord>'
/usr/local/lib/ruby/gems/2.2.0/gems/activerecord-4.2.4/lib/active_record/tasks/database_tasks.rb:3:in `<top (required)>'
/usr/local/lib/ruby/gems/2.2.0/gems/activerecord-4.2.4/lib/active_record/railtie.rb:41:in `block (3 levels) in <class:Railtie>'
Gem::LoadError: can't activate mysql2 (~> 0.3.13), already activated mysql2-0.4.0. Make sure all dependencies are added to Gemfile.
/usr/local/lib/ruby/gems/2.2.0/gems/bundler-1.10.6/lib/bundler/rubygems_integration.rb:302:in `block in replace_gem'
/usr/local/lib/ruby/gems/2.2.0/gems/activerecord-4.2.4/lib/active_record/connection_adapters/mysql2_adapter.rb:3:in `<top (required)>'
/usr/local/lib/ruby/gems/2.2.0/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:274:in `require'
/usr/local/lib/ruby/gems/2.2.0/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:274:in `block in require'
/usr/local/lib/ruby/gems/2.2.0/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:240:in `load_dependency'
/usr/local/lib/ruby/gems/2.2.0/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:274:in `require'
/usr/local/lib/ruby/gems/2.2.0/gems/activerecord-4.2.4/lib/active_record/connection_adapters/connection_specification.rb:175:in `spec'
/usr/local/lib/ruby/gems/2.2.0/gems/activerecord-4.2.4/lib/active_record/connection_handling.rb:50:in `establish_connection'
/usr/local/lib/ruby/gems/2.2.0/gems/activerecord-4.2.4/lib/active_record/railtie.rb:120:in `block (2 levels) in <class:Railtie>'
/usr/local/lib/ruby/gems/2.2.0/gems/activesupport-4.2.4/lib/active_support/lazy_load_hooks.rb:38:in `instance_eval'
/usr/local/lib/ruby/gems/2.2.0/gems/activesupport-4.2.4/lib/active_support/lazy_load_hooks.rb:38:in `execute_hook'
/usr/local/lib/ruby/gems/2.2.0/gems/activesupport-4.2.4/lib/active_support/lazy_load_hooks.rb:45:in `block in run_load_hooks'
/usr/local/lib/ruby/gems/2.2.0/gems/activesupport-4.2.4/lib/active_support/lazy_load_hooks.rb:44:in `each'
/usr/local/lib/ruby/gems/2.2.0/gems/activesupport-4.2.4/lib/active_support/lazy_load_hooks.rb:44:in `run_load_hooks'
/usr/local/lib/ruby/gems/2.2.0/gems/activerecord-4.2.4/lib/active_record/base.rb:315:in `<module:ActiveRecord>'
/usr/local/lib/ruby/gems/2.2.0/gems/activerecord-4.2.4/lib/active_record/base.rb:26:in `<top (required)>'
/usr/local/lib/ruby/gems/2.2.0/gems/activerecord-4.2.4/lib/active_record/tasks/mysql_database_tasks.rb:8:in `<class:MySQLDatabaseTasks>'
/usr/local/lib/ruby/gems/2.2.0/gems/activerecord-4.2.4/lib/active_record/tasks/mysql_database_tasks.rb:3:in `<module:Tasks>'
/usr/local/lib/ruby/gems/2.2.0/gems/activerecord-4.2.4/lib/active_record/tasks/mysql_database_tasks.rb:2:in `<module:ActiveRecord>'
/usr/local/lib/ruby/gems/2.2.0/gems/activerecord-4.2.4/lib/active_record/tasks/mysql_database_tasks.rb:1:in `<top (required)>'
/usr/local/lib/ruby/gems/2.2.0/gems/activerecord-4.2.4/lib/active_record/tasks/database_tasks.rb:50:in `<module:DatabaseTasks>'
/usr/local/lib/ruby/gems/2.2.0/gems/activerecord-4.2.4/lib/active_record/tasks/database_tasks.rb:37:in `<module:Tasks>'
/usr/local/lib/ruby/gems/2.2.0/gems/activerecord-4.2.4/lib/active_record/tasks/database_tasks.rb:4:in `<module:ActiveRecord>'
/usr/local/lib/ruby/gems/2.2.0/gems/activerecord-4.2.4/lib/active_record/tasks/database_tasks.rb:3:in `<top (required)>'
/usr/local/lib/ruby/gems/2.2.0/gems/activerecord-4.2.4/lib/active_record/railtie.rb:41:in `block (3 levels) in <class:Railtie>'
Tasks: TOP => db:schema:dump => db:load_config
(See full trace by running task with --trace)
Can somebody please tell me what is wrong? What do I need to do in order to solve this problem, I've done nothing but creating an empty project.
Just downgrade mysql gem gem 'mysql2', '~> 0.3.20'
It's a bug
For new coders (like me) gem 'mysql2', '~> 0.3.20' is NOT a command!
You will get the error "Unknown command mysql2" if you try.
vi/Edit the Gemfile and append
replace
gem 'mysql2'
with
gem 'mysql2', '~> 0.3.20'
save
then type the command:
bundle install
Then retry your rake db:________ command.

delayed_job daemon killed with error "Lost connection to MySQL server."

I have an application with the delayed jobs daemonized.
This daemonized delayed jobs process is being killed often.
But, when I invoke rake jobs:work manually, the corresponding delayedjob process doesn't get killed.
I am experiencing two scenarios with this issue:
The first scenario has the error listed in the log file
ImportSQLJob failed with ActiveRecord::StatementInvalid: Mysql2::Error: Lost connection to MySQL server during query: DELETE FROM `delayed_jobs` WHERE (`delayed_jobs`.`id` = 93528940) - 0 failed attempts
And delayed_job has been locked by the system.
The pid created exists in the applications "/tmp/pids/" folder but upon the checking the system process using ps -aux, couldn't find the process mentioned.
In the second scenario, the daemonized delayed_jobs process was killed without any errors in the log file, but here the jobs are not being locked and couldn't find the pids in the application's /tmp/pids/ directory. This is same as the one mentioned in the Google Groups thread. In that thread, Andrew Havens mentioned, regarding a patch for the daemons gem, that the srand() function was causing the issue. I couldn't find the patch made by him as the Rubyforge website is down permanently.
Upon checking the other posts in Stack Overflow, I suspect the issue to be either with the daemons gem or the mysql2 gem, but couldn't come to a conclusion because of my limited Rails knowledge.
And earlier I had a MySQL server go away issue and I added reconnect: true to my database.yml file which fixed that issue.
My production environment is:
OS: Ubuntu 12.04 LTS
Ruby version:1.9.3-p429
The gems which I use for my application are:
actionmailer (3.2.2)
actionpack (3.2.2)
activemodel (3.2.2)
activerecord (3.2.2)
activeresource (3.2.2)
activesupport (3.2.2)
arel (3.0.2)
builder (3.0.4)
bundler (1.3.5)
bundler-unload (1.0.1)
choice (0.1.6)
coffee-rails (3.2.2)
coffee-script (2.2.0)
coffee-script-source (1.4.0)
composite_primary_keys (5.0.8)
country-select (1.1.1)
daemon_controller (1.1.0)
daemons (1.1.9)
delayed_job (3.0.4)
delayed_job_active_record (0.3.3)
erubis (2.7.0)
eventmachine (1.0.0)
execjs (1.4.0)
faraday (0.8.4)
fastthread (1.0.7)
google-spreadsheet-ruby (0.3.0)
google_drive (0.3.2)
hike (1.2.1)
httpauth (0.2.0)
i18n (0.6.1)
journey (1.0.4)
jquery-rails (2.1.3)
jquery-ui-rails (4.1.2)
json (1.7.5)
jwt (0.1.5)
libv8 (3.11.8.13 x86-linux)
log4r (1.1.10)
mail (2.4.4)
mime-types (1.19)
multi_json (1.3.7)
multipart-post (1.1.5)
mysql2 (0.3.11)
net-scp (1.2.1)
net-ssh (2.9.0)
nokogiri (1.5.5)
oauth (0.4.7)
oauth2 (0.8.0)
passenger (3.0.18)
polyglot (0.3.3)
rack (1.4.1)
rack-cache (1.2)
rack-ssl (1.3.2)
rack-test (0.6.2)
rails (3.2.2)
railties (3.2.2)
rake (10.0.4, 10.0.1)
rdoc (3.12)
ref (1.0.2)
roo (1.10.1)
ruby-ole (1.2.11.5)
rubygems-bundler (1.2.0)
rubyzip (0.9.9)
rvm (1.11.3.8)
sass (3.2.3)
sass-rails (3.2.5)
spreadsheet (0.7.4)
sprockets (2.1.3)
therubyracer (0.11.4)
thin (1.5.0)
thor (0.14.6)
tilt (1.3.3)
todonotes (0.1.0)
treetop (1.4.12)
tzinfo (0.3.35)
uglifier (1.3.0)
will_paginate (3.0.3)
xml-simple (1.1.2)
And the database.yml file is:
production:
adapter: mysql2
encoding: utf8
database: smt_production
pool: 5
username: ****
password: ****
reconnect: true

Using Ruby and XEROUND on Heroku

First I would like to know if anyone has successfully built a Ruby on Rails application on Heroku using the XEROUND Add-on?
My PHP app works fine with the XEROUND Add-on (same database).
My Ruby application however, errors on starting.
We're sorry, but something went wrong.
On my development machine, When I run:
rails server -e production
the program starts with no problem.
When I push the code to Heroku and start the app
I get the Were sorry error.
Any ideas?
Is there anyway to output the database variables, right after they are assigned? As far as I know this would mean modifying the active-record adapter.
Is this a problem with Ruby itself? Should it have even gotten into the connection pool?
Would I be better off using XEROUND outside of Heroku (not as an Add-on)?
My database.yml contains
production:
adapter: mysql2
encoding: utf8
database: <%= ENV['XEROUND_DATABASE_NAME'] %>
username: <%= ENV['XEROUND_DATABASE_USERNAME'] %>
password: <%= ENV['XEROUND_DATABASE_PASSWORD'] %>
host: <%= ENV['XEROUND_DATABASE_HOST'] %>
port: <%= ENV['XEROUND_DATABASE_PORT'] %>
I get the same message when I hardcode the values.
Build information on Heroku:
git push heroku master
Counting objects: 15, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (10/10), done.
Writing objects: 100% (10/10), 1.19 KiB, done.
Total 10 (delta 7), reused 0 (delta 0)
-----> Heroku receiving push
-----> Ruby/Rails app detected
-----> Installing dependencies using Bundler version 1.2.1
Running: bundle install --without development:test --path vendor/bundle - -binstubs bin/
Fetching gem metadata from ....rubygems.org/.........
Using rake (0.9.2.2)
Using i18n (0.6.1)
Using multi_json (1.3.6)
Using activesupport (3.2.1)
Using builder (3.0.3)
Using activemodel (3.2.1)
Using erubis (2.7.0)
Using journey (1.0.4)
Using rack (1.4.1)
Using rack-cache (1.2)
Using rack-test (0.6.2)
Using hike (1.2.1)
Using tilt (1.3.3)
Using sprockets (2.1.3)
Using actionpack (3.2.1)
Using mime-types (1.19)
Using polyglot (0.3.3)
Using treetop (1.4.10)
Using mail (2.4.4)
Using actionmailer (3.2.1)
Using arel (3.0.2)
Using tzinfo (0.3.33)
Using activerecord (3.2.1)
Using mysql2 (0.3.11)
Using activerecord-mysql2-adapter (0.0.3)
Using activeresource (3.2.1)
Using bundler (1.2.1)
Using coffee-script-source (1.3.3)
Using execjs (1.4.0)
Using coffee-script (2.2.0)
Using rack-ssl (1.3.2)
Using json (1.7.5)
Using rdoc (3.12)
Using thor (0.14.6)
Using railties (3.2.1)
Using coffee-rails (3.2.2)
Using jquery-rails (2.1.3)
Using rails (3.2.1)
Using sass (3.2.1)
Using sass-rails (3.2.5)
Using uglifier (1.3.0)
Your bundle is complete! It was installed into ./vendor/bundle
Cleaning up the bundler cache.
-----> Writing config/database.yml to read from DATABASE_URL
-----> Preparing app for Rails asset pipeline
Detected manifest.yml, assuming assets were compiled locally
-----> Rails plugin injection
Injecting rails_log_stdout
Injecting rails3_serve_static_assets
-----> Discovering process types
Procfile declares types -> (none)
Default types for Ruby/Rails -> console, rake, web, worker
-----> Compiled slug size: 8.7MB
-----> Launching... done, v18
....shielded-brushlands-3293.herokuapp.com deployed to Heroku
To git#heroku.com:shielded-brushlands-3293.git
73c5cb6..c391a47 master -> master
The Heroku log shows:
2012-09-30T00:58:10+00:00 app[web.1]: => Booting WEBrick
2012-09-30T00:58:10+00:00 app[web.1]: => Rails 3.2.1 application starting in production on ...0.0.0.0:6832
2012-09-30T00:58:10+00:00 app[web.1]: => Call with -d to detach
2012-09-30T00:58:10+00:00 app[web.1]: => Ctrl-C to shutdown server
2012-09-30T00:58:10+00:00 app[web.1]: Started GET "/" for 76.87.97.210 at 2012-09-30 00:58:10 +0000
2012-09-30T00:58:15+00:00 heroku[router]: GET shielded-brushlands-3293.herokuapp.com/ dyno=web.1 queue=0 wait=0ms service=4529ms status=500 bytes=643
2012-09-30T00:58:15+00:00 app[web.1]: ActiveRecord::ConnectionNotEstablished (ActiveRecord::ConnectionNotEstablished):
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.1/lib/active_record/connection_adapters/abstract/connection_specification.rb:142:in `connection'
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.1/lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/railties-3.2.1/lib/rails/rack/logger.rb:26:in `call_app'
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.1/lib/active_support/cache/strategy/local_cache.rb:72:in `call'
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb:66:in `call!'
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.1/lib/active_support/callbacks.rb:81:in `run_callbacks'
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/railties-3.2.1/lib/rails/rack/logger.rb:16:in `call'
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/lock.rb:15:in `call'
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb:51:in `call'
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.1/lib/action_dispatch/middleware/callbacks.rb:27:in `call'
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/railties-3.2.1/lib/rails/rack/log_tailer.rb:14:in `call'
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.1/lib/action_dispatch/middleware/request_id.rb:22:in `call'
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.1/lib/action_dispatch/middleware/static.rb:53:in `call'
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.1/lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb:136:in `forward'
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/handler/webrick.rb:59:in `service'
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/methodoverride.rb:21:in `call'
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.1/lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/runtime.rb:17:in `call'
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb:245:in `fetch'
2012-09-30T00:58:15+00:00 app[web.1]: /usr/local/lib/ruby/1.9.1/webrick/httpserver.rb:111:in `service'
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.1/lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
2012-09-30T00:58:15+00:00 app[web.1]:
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/railties-3.2.1/lib/rails/engine.rb:479:in `call'
2012-09-30T00:58:15+00:00 app[web.1]: /usr/local/lib/ruby/1.9.1/webrick/httpserver.rb:70:in `run'
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.1/lib/active_record/query_cache.rb:67:in `rescue in call'
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:374:in `retrieve_connection'
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/content_length.rb:14:in `call'
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb:185:in `lookup'
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/railties-3.2.1/lib/rails/application.rb:220:in `call'
2012-09-30T00:58:15+00:00 app[web.1]: cache: [GET /] miss
2012-09-30T00:58:15+00:00 app[web.1]:
2012-09-30T00:58:15+00:00 app[web.1]:
2012-09-30T00:58:15+00:00 app[web.1]: /usr/local/lib/ruby/1.9.1/webrick/server.rb:183:in `block in start_thread'
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.1/lib/active_record/connection_adapters/abstract/connection_specification.rb:168:in `retrieve_connection'
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.1/lib/active_record/query_cache.rb:61:in `call'
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:443:in `call'
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.1/lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.1/lib/active_support/callbacks.rb:405:in `_run__2306900267479677068__call__3522025195442796026__callbacks'
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.1/lib/active_support/callbacks.rb:405:in `__run_callback'
2012-09-30T00:58:15+00:00 heroku[router]: GET shielded-brushlands-3293.herokuapp.com/favicon.ico dyno=web.1 queue=0 wait=0ms service=17ms status=200 bytes=0
2012-09-30T00:58:15+00:00 app[web.1]: cache: [GET /favicon.ico] miss, store
The gemfile.lock
GEM
remote: ....rubygems.org/
specs:
actionmailer (3.2.1)
actionpack (= 3.2.1)
mail (~> 2.4.0)
actionpack (3.2.1)
activemodel (= 3.2.1)
activesupport (= 3.2.1)
builder (~> 3.0.0)
erubis (~> 2.7.0)
journey (~> 1.0.1)
rack (~> 1.4.0)
rack-cache (~> 1.1)
rack-test (~> 0.6.1)
sprockets (~> 2.1.2)
activemodel (3.2.1)
activesupport (= 3.2.1)
builder (~> 3.0.0)
activerecord (3.2.1)
activemodel (= 3.2.1)
activesupport (= 3.2.1)
arel (~> 3.0.0)
tzinfo (~> 0.3.29)
activerecord-mysql2-adapter (0.0.3)
mysql2
activeresource (3.2.1)
activemodel (= 3.2.1)
activesupport (= 3.2.1)
activesupport (3.2.1)
i18n (~> 0.6)
multi_json (~> 1.0)
arel (3.0.2)
builder (3.0.0)
coffee-rails (3.2.2)
coffee-script (>= 2.2.0)
railties (~> 3.2.0)
coffee-script (2.2.0)
coffee-script-source
execjs
coffee-script-source (1.3.3)
erubis (2.7.0)
execjs (1.4.0)
multi_json (~> 1.0)
hike (1.2.1)
i18n (0.6.0)
journey (1.0.4)
jquery-rails (2.1.1)
railties (>= 3.1.0, < 5.0)
thor (~> 0.14)
json (1.7.5)
mail (2.4.4)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
mime-types (1.19)
multi_json (1.3.6)
mysql2 (0.3.11)
polyglot (0.3.3)
rack (1.4.1)
rack-cache (1.2)
rack (>= 0.4)
rack-ssl (1.3.2)
rack
rack-test (0.6.1)
rack (>= 1.0)
rails (3.2.1)
actionmailer (= 3.2.1)
actionpack (= 3.2.1)
activerecord (= 3.2.1)
activeresource (= 3.2.1)
activesupport (= 3.2.1)
bundler (~> 1.0)
railties (= 3.2.1)
railties (3.2.1)
actionpack (= 3.2.1)
activesupport (= 3.2.1)
rack-ssl (~> 1.3.2)
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (~> 0.14.6)
rake (0.9.2.2)
rdoc (3.12)
json (~> 1.4)
sass (3.2.1)
sass-rails (3.2.5)
railties (~> 3.2.0)
sass (>= 3.1.10)
tilt (~> 1.3)
sprockets (2.1.3)
hike (~> 1.2)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
thor (0.14.6)
tilt (1.3.3)
treetop (1.4.10)
polyglot
polyglot (>= 0.3.1)
tzinfo (0.3.33)
uglifier (1.2.7)
execjs (>= 0.3.0)
multi_json (~> 1.3)
PLATFORMS
ruby
DEPENDENCIES
activerecord-mysql2-adapter
coffee-rails (~> 3.2.1)
jquery-rails
mysql2
rails (= 3.2.1)
sass-rails (~> 3.2.3)
uglifier (>= 1.0.3)
I did an internet search on: xeround heroku ruby
The first item on the list:
https://devcenter.heroku.com/articles/xeround
So if I can use heroku config to set variables, then I should be able to see all variables
Next search on: heroku config
The first item on the list:
https://devcenter.heroku.com/articles/config-vars
In the config-vars article (from 2nd search) I can issue the command: heroku config
heroku config
! autoupdate in progress
=== shielded-brushlands-3293 Config Vars
DATABASE_URL: postgres://hvsosprakvuedm:v5QU211mYByXbBIdAxa3s4oMff#ec2-107-20-195-105.compute-1.amazonaws.com:5432/dehgili4ph7ih7
GEM_PATH: vendor/bundle/ruby/1.9.1
LANG: en_US.UTF-8
PATH: bin:vendor/bundle/ruby/1.9.1/bin:/usr/local/bin:/usr/bin:/bin
RACK_ENV: production
RAILS_ENV: production
XEROUND_DATABASE_ADAPTER: mysql
XEROUND_DATABASE_FAILOVER_ADAPTER: mysql
XEROUND_DATABASE_FAILOVER_HOST: instance27464.db.xeround.com.
XEROUND_DATABASE_FAILOVER_NAME: app7912272
XEROUND_DATABASE_FAILOVER_PASSWORD: xxxxx
XEROUND_DATABASE_FAILOVER_PORT: 16304
XEROUND_DATABASE_FAILOVER_URL: mysql://app7912272:xxxx#instance27464.db.xeround.com.:16304/app7912272
XEROUND_DATABASE_FAILOVER_USERNAME: app7912272
XEROUND_DATABASE_HOST: instance27464.db.xeround.com.
XEROUND_DATABASE_INTERNAL_ADAPTER: mysql
XEROUND_DATABASE_INTERNAL_HOST: int.instance27464.db.xeround.com.
XEROUND_DATABASE_INTERNAL_NAME: app7912272
XEROUND_DATABASE_INTERNAL_PASSWORD: xxxxx
XEROUND_DATABASE_INTERNAL_PORT: 16304
XEROUND_DATABASE_INTERNAL_URL: mysql://app7912272:xxxx#int.instance27464.db.xeround.com.:16304/app7912272
XEROUND_DATABASE_INTERNAL_USERNAME: app7912272
XEROUND_DATABASE_NAME: app7912272
XEROUND_DATABASE_PASSWORD: xxxxx
XEROUND_DATABASE_PORT: 16304
XEROUND_DATABASE_URL: mysql://app7912272:xxxx#instance27464.db.xeround.com.:16304/app7912272
XEROUND_DATABASE_USERNAME: app7912272
The first one caught my attention, its pointing to a postgres location.
Does it matter? I'm not referencing DATABASE_URL.
The xeround article (from 1st search) contained a line, but didn't get into why, it just said do it.
Connecting to xeround
The Xeround add-on will store the database’s URLs in two config vars:
XEROUND_DATABASE_URL and XEROUND_DATABASE_INTERNAL_URL
The “internal” URL is translated to internal IP addresses and should be used when accessing your database from within the same datacenter.
The first URL is used for connecting from outside.
Copy the value of the config variable that is relevant for you -
$ heroku config:add DATABASE_URL=(URL config vars)
Hmmm? It is not a variable I refrence in my program, nor is it set on my local machine.
Here it goes:
Since this is supposed to be a cloud database, I should not need to know anything about datacenter locations, so going with external.
heroku config:add DATABASE_URL=mysql://app7912272:xxxx#instance27464.db.xeround.com.:16304/app7912272
Setting config vars and restarting shielded-brushlands-3293... !
Autoupdate in progress
done, v20
DATABASE_URL: mysql://app7912272:XXXX#instance27464.db.xeround.com.:16304/app7912272
Lets see if it comes up....
Crap
Okay set it to internal:
heroku config:add DATABASE_URL=mysql://app7912272:xxxx#int.instance27464.db.xeround.com.:16304/app7912272
Lets see if it comes up....
Crap II
I also noticed there are two variables called XEROUND_DATABASE_ADAPTER, XEROUND_DATABASE_FAILOVER_ADAPTER and XEROUND_DATABASE_INTERNAL_ADAPTER.
They are both set to mysql.
I am using mysql2.
heroku config:add XEROUND_DATABASE_ADAPTER=mysql2
heroku config:add XEROUND_DATABASE_FAILOVER_ADAPTER=mysql2
herokU config:add XEROUND_DATABASE_INTERNAL_ADAPTER=mysql2
Lets see if it comes up....
Crap III
Further down in the article:
Each of the URLs contains a string of the following syntax:
mysql://username:password#host:port/database
The parts out of which the URLs are made of are also set for your convenience in the following environment variables:
XEROUND_DATABASE_ADAPTER
XEROUND_DATABASE_USERNAME
XEROUND_DATABASE_PASSWORD
XEROUND_DATABASE_HOST
XEROUND_DATABASE_PORT
XEROUND_DATABASE_NAME
XEROUND_DATABASE_INTERNAL_ADAPTER
XEROUND_DATABASE_INTERNAL_USERNAME
XEROUND_DATABASE_INTERNAL_PASSWORD
XEROUND_DATABASE_INTERNAL_HOST
XEROUND_DATABASE_INTERNAL_PORT
XEROUND_DATABASE_INTERNAL_NAME
Anyone who has been around programming long enough, probably knows where this is going. Sometimes you do things, even though they make no sense.
So the mysql: is derived from the adapter.
Update the url variables as well:
heroku config:add DATABASE_URL=mysql2://app7912272:xxxx#instance27464.db.xeround.com.:16304/app7912272
heroku config:add XEROUND_DATABASE_URL=mysql2://app7912272:xxxxxx#instance27464.db.xeround.com.:16304/app7912272
heroku config:add XEROUND_DATABASE_FAILOVER_URL=mysql2://app7912272:xxxxxx#instance27464.db.xeround.com.:16304/app7912272
herokU config:add XEROUND_DATABASE_INTERNAL_URL=mysql2://app7912272:xxxxxx#instance27464.db.xeround.com.:16304/app7912272
No crap, the application came up
A final look:
heroku config
! autoupdate in progress
=== shielded-brushlands-3293 Config Vars
DATABASE_URL: mysql2://app7912272:xxxx#instance27464.db.xeround.com.:16304/app7912272
GEM_PATH: vendor/bundle/ruby/1.9.1
LANG: en_US.UTF-8
PATH: bin:vendor/bundle/ruby/1.9.1/bin:/usr/local bin:/usr/bin:/bin
RACK_ENV: production
RAILS_ENV: production
XEROUND_DATABASE_ADAPTER: mysql2
XEROUND_DATABASE_FAILOVER_ADAPTER: mysql2
XEROUND_DATABASE_FAILOVER_HOST: instance27464.db.xeround.com.
XEROUND_DATABASE_FAILOVER_NAME: app7912272
XEROUND_DATABASE_FAILOVER_PASSWORD: xxxx
XEROUND_DATABASE_FAILOVER_PORT: 16304
XEROUND_DATABASE_FAILOVER_URL: mysql2://app7912272:xxxx#instance27464.db.xeround.com.:16304/app7912272
XEROUND_DATABASE_FAILOVER_USERNAME: app7912272
XEROUND_DATABASE_HOST: instance27464.db.xeround.com.
XEROUND_DATABASE_INTERNAL_ADAPTER: mysql2
XEROUND_DATABASE_INTERNAL_HOST: int.instance27464.db.xeround.com.
XEROUND_DATABASE_INTERNAL_NAME: app7912272
XEROUND_DATABASE_INTERNAL_PASSWORD: xxxx
XEROUND_DATABASE_INTERNAL_PORT: 16304
XEROUND_DATABASE_INTERNAL_URL: mysql2://app7912272:xxxx#instance27464.db.xeround.com.:16304/app7912272
XEROUND_DATABASE_INTERNAL_USERNAME: app7912272
XEROUND_DATABASE_NAME: app7912272
XEROUND_DATABASE_PASSWORD: xxxx
XEROUND_DATABASE_PORT: 16304
XEROUND_DATABASE_URL: mysql2://app7912272:xxxx#instance27464.db.xeround.com.:16304/app7912272
XEROUND_DATABASE_USERNAME: app7912272
Since the mysql2 gem is the default w/ Rails 3 all you need to do is make sure you have "gem 'mysql2'" in your gemfile, and run bundle install, commit/push to heroku
Then of course use your URL listed in heroku config under "XEROUND_DATABASE_URL"
heroku config:add DATABASE_URL=mysql2://app7912272:xxxx#instance27464.db.xeround.com.:16304/app7912272
Note the changing the mysql:// to mysql2:// (this is the key)
Then
heroku restart
I JUST did this on a brand new Rails 3.2.9 Heroku app running Xeround with success. There was no need to change the adapter to "mysql2"

Installing mysql2 gem on mac with RVM is real pain

Step 1:--
rails s/usr/local/rvm/gems/ruby-1.9.2-p180/gems/mysql2-0.3.2/lib/mysql2.rb:8:in `require': dlopen(/usr/local/rvm/gems/ruby-1.9.2-p180/gems/mysql2-0.3.2/lib/mysql2/mysql2.bundle, 9): Library not loaded: libmysqlclient.16.dylib (LoadError)
Referenced from: /usr/local/rvm/gems/ruby-1.9.2-p180/gems/mysql2-0.3.2/lib/mysql2/mysql2.bundle
Reason: image not found - /usr/local/rvm/gems/ruby-1.9.2-p180/gems/mysql2-0.3.2/lib/mysql2/mysql2.bundle
from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/mysql2-0.3.2/lib/mysql2.rb:8:in `<top (required)>'
from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.12/lib/bundler/runtime.rb:68:in `require'
from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.12/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.12/lib/bundler/runtime.rb:66:in `each'
from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.12/lib/bundler/runtime.rb:66:in `block in require'
from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.12/lib/bundler/runtime.rb:55:in `each'
from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.12/lib/bundler/runtime.rb:55:in `require'
from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.12/lib/bundler.rb:120:in `require'
from /Users/mohit/projects/lbs_admin/config/application.rb:7:in `<top (required)>'
from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.3/lib/rails/commands.rb:28:in `require'
from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.3/lib/rails/commands.rb:28:in `block in <top (required)>'
from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.3/lib/rails/commands.rb:27:in `tap'
from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.3/lib/rails/commands.rb:27:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
STEP 2:--
sudo install_name_tool -change libmysqlclient.16.dylib /usr/local/mysql-5.5.9-osx10.6-x86_64/lib/libmysqlclient.16.dylib /usr/local/rvm/gems/ruby-1.9.2-p180/gems/mysql2-0.3.2/lib/mysql2/mysql2.bundle
Result:--
rails sWARNING: This version of mysql2 (0.3.2) doesn't ship with the ActiveRecord adapter bundled anymore as it's now part of Rails 3.1
WARNING: Please use the 0.2.x releases if you plan on using it in Rails <= 3.0.x
=> Booting WEBrick
=> Rails 3.0.3 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
/usr/local/rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.0.3/lib/active_record/connection_adapters/abstract/connection_specification.rb:71:in `rescue in establish_connection': Please install the mysql2 adapter: `gem install activerecord-mysql2-adapter` (no such file to load -- active_record/connection_adapters/mysql2_adapter) (RuntimeError)
from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.0.3/lib/active_record/connection_adapters/abstract/connection_specification.rb:68:in `establish_connection'
from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.0.3/lib/active_record/connection_adapters/abstract/connection_specification.rb:60:in `establish_connection'
from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.0.3/lib/active_record/connection_adapters/abstract/connection_specification.rb:55:in `establish_connection'
from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.0.3/lib/active_record/railtie.rb:59:in `block (2 levels) in <class:Railtie>'
from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.0.3/lib/active_support/lazy_load_hooks.rb:36:in `instance_eval'
from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.0.3/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook'
from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.0.3/lib/active_support/lazy_load_hooks.rb:43:in `block in run_load_hooks'
from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.0.3/lib/active_support/lazy_load_hooks.rb:42:in `each'
from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.0.3/lib/active_support/lazy_load_hooks.rb:42:in `run_load_hooks'
from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.0.3/lib/active_record/base.rb:1891:in `<top (required)>'
from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/will_paginate-3.0.pre2/lib/will_paginate/finders/active_record.rb:31:in `enable!'
from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/will_paginate-3.0.pre2/lib/will_paginate/railtie.rb:9:in `block in <class:Railtie>'
from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.3/lib/rails/initializable.rb:25:in `instance_exec'
from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.3/lib/rails/initializable.rb:25:in `run'
from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.3/lib/rails/initializable.rb:50:in `block in run_initializers'
from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.3/lib/rails/initializable.rb:49:in `each'
from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.3/lib/rails/initializable.rb:49:in `run_initializers'
from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.3/lib/rails/application.rb:134:in `initialize!'
from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.3/lib/rails/application.rb:77:in `method_missing'
from /Users/mohit/projects/lbs_admin/config/environment.rb:5:in `<top (required)>'
from /Users/mohit/projects/lbs_admin/config.ru:3:in `require'
from /Users/mohit/projects/lbs_admin/config.ru:3:in `block in <main>'
from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/rack-1.2.2/lib/rack/builder.rb:46:in `instance_eval'
from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/rack-1.2.2/lib/rack/builder.rb:46:in `initialize'
from /Users/mohit/projects/lbs_admin/config.ru:1:in `new'
from /Users/mohit/projects/lbs_admin/config.ru:1:in `<main>'
from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/rack-1.2.2/lib/rack/builder.rb:35:in `eval'
from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/rack-1.2.2/lib/rack/builder.rb:35:in `parse_file'
from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/rack-1.2.2/lib/rack/server.rb:162:in `app'
from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/rack-1.2.2/lib/rack/server.rb:248:in `wrapped_app'
from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/rack-1.2.2/lib/rack/server.rb:213:in `start'
from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.3/lib/rails/commands/server.rb:65:in `start'
from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.3/lib/rails/commands.rb:30:in `block in <top (required)>'
from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.3/lib/rails/commands.rb:27:in `tap'
from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.3/lib/rails/commands.rb:27:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
Step 3:--
sudo gem uninstall mysql2
sudo env ARCHFLAGS="-arch i386" gem install mysql2 -- --with-mysql-config=/usr/local/mysql-5.5.9-osx10.6-x86_64/bin/mysql_config
Current status:--
ruby -v
ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-darwin10.7.0]
rails -v
Rails 3.0.3
gem list
*** LOCAL GEMS ***
abstract (1.0.0)
actionmailer (3.0.7, 3.0.3)
actionpack (3.0.7, 3.0.3)
activemodel (3.0.7, 3.0.3)
activerecord (3.0.7, 3.0.3)
activeresource (3.0.7, 3.0.3)
activesupport (3.0.7, 3.0.3)
annotate-models (1.0.4)
arel (2.0.9)
builder (2.1.2)
bundler (1.0.12)
erubis (2.6.6)
i18n (0.5.0)
mail (2.2.19)
mime-types (1.16)
mysql2 (0.3.2)
polyglot (0.3.1)
rack (1.2.2)
rack-mount (0.6.14)
rack-test (0.5.7)
rails (3.0.7, 3.0.3)
railties (3.0.7, 3.0.3)
rake (0.8.7)
thor (0.14.6)
treetop (1.4.9)
tzinfo (0.3.27)
web-app-theme (0.6.3)
will_paginate (3.0.pre2)
locate mysql_config
/usr/local/mysql-5.5.9-osx10.6-x86_64/bin/mysql_config
/usr/local/mysql-5.5.9-osx10.6-x86_64/man/man1/mysql_config.1
bundle show mysql2
/usr/local/rvm/gems/ruby-1.9.2-p180/gems/mysql2-0.3.2
locate libmysqlclient.16.dylib
/usr/local/mysql-5.5.9-osx10.6-x86_64/lib/libmysqlclient.16.dylib
How can I proceed?
I have the sam problem. What I did is doing;
gem install --version '0.2.7' mysql2
Then on your Rails's GemFile. Should look like this.
gem 'mysql2', '0.2.7'
Then try again. Hope it help.
Your stacktrace after Step 2 told you what to do:
Please install the mysql2 adapter: gem install activerecord-mysql2-adapter
Update
Also, upgrade your Rails to 3.0.7 - there are a number of security holes (and bugs) in 3.0.3.
Update
Looks like that error message from Rails is wrong, it should have read:
Please use the 0.2.x releases if you plan on using it in Rails <= 3.1
Ie. for anything less than 3.1 you need to pin mysql2 to the 0.2 release, and not allow it to use 0.3. To do this, change your mysql2 line in your Gemfile to this:
gem "mysql2", "~> 0.2"
Then re-run bundle install
rails sWARNING: This version of mysql2 (0.3.2) doesn't ship with the ActiveRecord adapter bundled anymore as it's now part of Rails 3.1
WARNING: Please use the 0.2.x releases if you plan on using it in Rails <= 3.0.x
MySql version '0.2.7' solved my issue.
gem 'mysql2', '0.2.7'
Try this (but I cannot guarantee anything)
Check this post about how to
remove MySQL 5.5.
install MySQL 5.1 (I think I downloaded the 32bit DMG version)
Follow this post to create the GEM.
Hopefully it will work after this. I'll cross my fingers for you.
The above problem occurs presently on EngineYard App Cloud with Ruby 1.9.2 and Rails 3.0.3. Using mysql 2.8.1 barfs b/c EY sets mysql2 adapter. Using mysql2 0.3.2 barfs. So I was seriously stumped. Props to Richard Soutar's answer. It worked.

error while trying to push database to heroku

I am trying to do a
$heroku db:push
this is the error I get
C:/Ruby/lib/ruby/gems/1.8/gems/rack-1.2.1/lib/rack/utils.rb:138:in `union': can't convert Array into
String (TypeError)
from C:/Ruby/lib/ruby/gems/1.8/gems/rack-1.2.1/lib/rack/utils.rb:138
from C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
from C:/Ruby/lib/ruby/gems/1.8/gems/taps-0.3.9/lib/taps/multipart.rb:2
from C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
from C:/Ruby/lib/ruby/gems/1.8/gems/taps-0.3.9/lib/taps/data_stream.rb:2
from C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
... 8 levels...
from C:/Ruby/lib/ruby/gems/1.8/gems/heroku-1.9.11/lib/heroku/command.rb:20:in `run'
from C:/Ruby/lib/ruby/gems/1.8/gems/heroku-1.9.11/bin/heroku:13
from C:/Ruby/bin/heroku:19:in `load'
from C:/Ruby/bin/heroku:19
It is a brand new MySQL development database, the taps gem is installed. I have pushed this same database to multiple other heroku apps, those have all been deleted.
Have you checked the version of rack gem?
try making it rack (1.0.1)
i.e gem uninstall rack <version number>
then gem install rack 1.0.1
Hope this helps,
Regards,
Saurabh