no such file to load -- mysql (LoadError) - ruby gems - mysql

I'm a newbie to ruby, trying to connect mysql servcer through Ruby for cucumber and getting the following error while running cukes.
error: no such file to load -- mysql (LoadError)
But installed mysql gem and here is my gem list and also has libmysql.dll under ruby_home\bin path
addressable (2.2.8)
builder (3.0.0)
bundler (1.1.4)
childprocess (0.3.3)
cucumber (1.2.1)
diff-lcs (1.1.3)
ffi (1.0.11, 1.0.9 x86-mingw
gherkin (2.11.1 x86-mingw32)
headless (0.2.2)
json (1.7.3)
libwebsocket (0.1.4)
minitest (1.6.0)
multi_json (1.3.6)
mysql (2.8.1 x86-mingw32)
mysql2 (0.3.11 x86-mingw32)
net-ldap (0.3.1)
rake (0.8.7)
rdoc (2.5.8)
rspec (2.10.0)
rspec-core (2.10.1)
rspec-expectations (2.10.0)
rspec-mocks (2.10.1)
rubygems-update (1.8.24)
rubyzip (0.9.9)
selenium-webdriver (2.24.0)
titleize (1.2.1)
watir-webdriver (0.6.1)
Any idea whats going on...

What version of Ruby are you running mate? If you're running 1.8 you need to add "require 'rubygems'" before your "require 'mysql'. If not then try requiring the gem in a non-explicit way. Something like this:
require_relative "rubygems"
require_relative "mysql"
If you want to give it a quick test use this code below..:
require "rubygems"
require "mysql"
begin
# connect to the MySQL server
db = Mysql.real_connect("localhost", "username", "password")
# get server version string and display it
puts "Server version: " + db.get_server_info
rescue Mysql::Error => e
puts "Error code: #{e.errno}"
puts "Error message: #{e.error}"
puts "Error SQLSTATE: #{e.sqlstate}" if e.respond_to?("sqlstate")
ensure
# disconnect from server
db.close if db
end
If all goes well you should see your mysql version..

Related

NameError: uninitialized constant ActiveRecord::ConnectionAdapters::MysqlAdapter while starting rails server

Please could anyone help me out with this. I am working on a project that is built in rails 3.2.13 (JRuby) using MySQL database. Whenever i start the server i get the below error.
rails s -e development -p3000
/JRuby-9.2.0.0/jruby-9.2.0.0/lib/ruby/gems/shared/gems/activesupport-3.2.13/lib/active_support/values/time_zone.rb:270: warning: circular argument reference - now
/JRuby-9.2.0.0/jruby-9.2.0.0/lib/ruby/gems/shared/gems/activesupport-3.2.13/lib/active_support/core_ext/object/duplicable.rb:111: warning: BigDecimal.new is deprecated
/JRuby-9.2.0.0/jruby-9.2.0.0/lib/ruby/gems/shared/gems/activerecord-3.2.13/lib/active_record/associations/has_many_association.rb:52: warning: circular argument reference - reflection
/JRuby-9.2.0.0/jruby-9.2.0.0/lib/ruby/gems/shared/gems/activerecord-3.2.13/lib/active_record/associations/has_many_association.rb:56: warning: circular argument reference - reflection
/JRuby-9.2.0.0/jruby-9.2.0.0/lib/ruby/gems/shared/gems/activerecord-3.2.13/lib/active_record/associations/has_many_association.rb:60: warning: circular argument reference - reflection
/JRuby-9.2.0.0/jruby-9.2.0.0/lib/ruby/gems/shared/gems/activerecord-3.2.13/lib/active_record/associations/has_many_association.rb:79: warning: circular argument reference - reflection
=> Booting WEBrick
=> Rails 3.2.13 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released.
DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. /home/jayvijay/RailsTestProject/config/environment.rb:5)
Thu Sep 27 19:42:40 IST /home/jayvijay/RailsTestProject/config/initializers/enhancements.rb:24: warning: constant ::Fixnum is deprecated
/home/jayvijay/RailsTestProject/config/initializers/enhancements.rb:24: warning: constant ::Bignum is deprecated
Exiting
NameError: uninitialized constant ActiveRecord::ConnectionAdapters::MysqlAdapter
I came to know that the below block in the config/initializers/enhancements.rb file is causing the flow to break.
# Patch taken from https://github.com/jruby/activerecord-jdbc-adapter/issues/229
require 'arjdbc/mysql/adapter'
ActiveRecord::ConnectionAdapters::MysqlAdapter.class_eval do
alias original_quote_string quote_string
def quote_string(s)
quoted_string = original_quote_string(s)
needs_encoding?(s, quoted_string) ? quoted_string.force_encoding('UTF-8') : quoted_string
end
private
def needs_encoding?(original_string, quoted_string)
!quoted_string.frozen? && original_string.length != quoted_string.length
end
end
So then i tried changing MysqlAdapter to Mysql2Adapter in the enhancements.rb file and tried starting the server again. This time the server started successfully but when i typed localhost:3000 onto the browser it produced the below error :
error_screenshot
Please could anyone advise on how to resolve the above issue.
Below are version details for:-
JRuby
jruby 9.2.0.0 (2.5.0) 2018-05-24 81156a8 OpenJDK 64-Bit Server VM 25.171-b11 on 1.8.0_171-8u171-b11-2~14.04-b11 +jit [linux-x86_64]
Rails
Rails 3.2.13
Gem Version
2.7.6
Bundler Version
Bundler version 1.16.5
Below is my gemfile:-
source 'http://rubygems.org'
gem 'rails', '=3.2.13'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'execjs'
gem 'therubyrhino'
gem 'json'
gem 'bcrypt-ruby'
gem 'activerecord-jdbc-adapter'
gem 'activerecord-jdbcmysql-adapter'
gem "jruby-openssl"
gem 'net-ldap'
gem 'enum_column3'
gem "auto_form"
gem "eav_presenter"
gem "warbler"
gem "composite_primary_keys"
gem "test-unit"
#for usual admin scaffolds for AR models. See admin_controller.rb
gem "scaffolding_extensions"
gem "active_presenter"
gem "will_paginate"
gem "bitfields"
# Gems used only for assets and not required
# in production environments by default.
group :assets do
# gem 'sass-rails'
gem 'coffee-rails'
gem 'uglifier'
end
group :qa do
gem "better_errors"
end
gem 'prototype-rails'
# Use unicorn as the web server
# gem 'unicorn'
# Deploy with Capistrano
# gem 'capistrano'
# To use debugger
# gem 'ruby-debug'
Below is my database.yml file:
# MySQL.  Versions 4.1 and 5.0 are recommended.
#
#
# Be sure to use new-style password hashing:
#   http://dev.mysql.com/doc/refman/5.0/en/old-client.html
default: &default
adapter: <%= ConfigClient.conn[:adapter] %>
database: <%= ConfigClient.conn[:database] %>
host: <%= ConfigClient.conn[:host] %>
username: <%= ConfigClient.conn[:username] %>
password: <%= ConfigClient.conn[:password] %>
port: <%= ConfigClient.conn[:port] %>
encoding: <%= ConfigClient.conn[:encoding] %>
pool: 30
timeout: 8000
development:
<<: *default
qa:
<<: *default
production:
<<: *default
ConfigClient File which is used above:-
require 'java'
require_relative './log4j-1.2.15.jar'
require_relative './mysql-connector-java-5.1.17-bin.jar'
class ConfigClient
def self.connection_params(db_name)
conn = get_prop(db_name, "CONNECTION_LIST").split("|")
default_connection_params.merge({
:database => conn[0],
:host => conn[1],
:port => conn[2],
:username => conn[3],
:password => conn[4]
})
end
def self.default_connection_params
{:adapter => "jdbcmysql", :encoding => "utf8", :reconnect => false, :pool => 30, :timeout => 8000}
end
def self.conn
connection_params("database.db.rw")
end
The below gems are installed in my system:-
gem list
*** LOCAL GEMS ***
actioncable (5.2.1)
actionmailer (5.2.1, 3.2.13)
actionpack (5.2.1, 3.2.13)
actionview (5.2.1)
active_presenter (3.2.2)
activejob (5.2.1)
activemodel (5.2.1, 3.2.13)
activerecord (5.2.1, 3.2.13)
activerecord-jdbc-adapter (50.0)
activerecord-jdbcmysql-adapter (50.0)
activeresource (3.2.13)
activestorage (5.2.1)
activesupport (5.2.1, 3.2.13)
arel (9.0.0, 3.0.3)
auto_form (0.0.2)
bcrypt (3.1.12 java)
bcrypt-ruby (3.1.5 java)
better_errors (2.5.0)
bitfields (0.8.0)
builder (3.2.3, 3.0.4)
bundler (1.16.5)
cmath (default: 1.0.0)
coderay (1.1.2)
coffee-rails (3.2.2)
coffee-script (2.4.1)
coffee-script-source (1.12.2)
composite_primary_keys (5.0.14)
concurrent-ruby (1.0.5 java)
crass (1.0.4)
csv (default: 1.0.0)
eav_presenter (0.3)
enum_column3 (0.1.4)
erubi (1.7.1)
erubis (2.7.0)
execjs (2.7.0)
fileutils (default: 1.1.0)
globalid (0.4.1)
hike (1.2.3)
httpclient (2.8.3)
i18n (1.1.0, 0.6.1)
ipaddr (default: 1.2.0)
jar-dependencies (default: 0.3.12)
jdbc-mysql (5.1.46)
journey (1.0.4)
jruby-jars (9.2.0.0)
jruby-openssl (0.10.1 java, default: 0.10.0 java)
jruby-rack (1.1.21)
jruby-readline (default: 1.2.2 java)
json (default: 2.1.0 java, 1.8.6 java)
loofah (2.2.2)
mail (2.7.0, 2.5.5)
marcel (0.3.3)
method_source (0.9.0)
mime-types (1.25.1)
mimemagic (0.3.2)
mini_mime (1.0.1)
minitest (5.11.3)
multi_json (1.13.1)
net-ldap (0.16.1)
nio4r (2.3.1 java)
nokogiri (1.8.4 java)
polyglot (0.3.5)
power_assert (1.1.3)
prototype-rails (3.2.1)
psych (default: 3.0.2 java)
rack (2.0.5, 1.4.7)
rack-cache (1.8.0)
rack-ssl (1.3.4)
rack-test (1.1.0, 0.6.3)
rails (3.2.13)
rails-dom-testing (2.0.3)
rails-html-sanitizer (1.0.4)
railties (5.2.1, 3.2.13)
rake (12.3.1)
rake-ant (default: 1.0.4)
rdoc (default: 6.0.1, 3.12.2)
rubyzip (1.2.2)
scaffolding_extensions (1.6.1)
scanf (default: 1.0.0)
sprockets (3.7.2, 2.2.3)
sprockets-rails (3.2.1)
test-unit (3.2.8)
therubyrhino (2.0.4)
therubyrhino_jar (1.7.6)
thor (0.20.0)
thread_safe (0.3.6 java)
tilt (1.4.1)
treetop (1.4.15)
tzinfo (1.2.5, 0.3.54)
uglifier (4.1.19)
validated_arguments (0.0.1)
warbler (2.0.5)
webrick (default: 1.4.2)
websocket-driver (0.7.0 java)
websocket-extensions (0.1.3)
will_paginate (3.1.6)
Is there any problem with the enhancements.rb file, do i have to change it? OR Is there any problem with the installed gems?. Please
Does anyone have any idea for this?. Any help would be appreciated.
Thanks,

Gem :: load error while migrating from MySQL to MongoDB

I am trying to migrate the Mysql DB to MongoDB using tool Mongify by referring the
documentation :
i have seen , there are few posts already present regarding such migration but they mentioned issues with rails application and some dependencies on rails. however, in my case , it is just simple migration without rails.
Environment details:
windows enterprise 7
Mysql community server : 5.7
Mongo db server : 4.0
ruby : ruby 2.5.1p57 (2018-03-29 revision 63029) [i386-mingw32]
Mysql c Connector (32 bit)
mysql server and mongo db server are working fine as a service.
rubygems environment details as follows :
RubyGems Environment:
- RUBYGEMS VERSION: 2.7.6
- RUBY VERSION: 2.5.1 (2018-03-29 patchlevel 57) [i386-mingw32]
- INSTALLATION DIRECTORY: C:/Ruby25/lib/ruby/gems/2.5.0
- USER INSTALLATION DIRECTORY: C:/Users/irfan.sayed/.gem/ruby/2.5.0
- RUBY EXECUTABLE: C:/Ruby25/bin/ruby.exe
- EXECUTABLE DIRECTORY: C:/Ruby25/bin
- SPEC CACHE DIRECTORY: C:/Users/irfan.sayed/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: C:/ProgramData
- RUBYGEMS PLATFORMS:
- ruby
- x86-mingw32
- GEM PATHS:
- C:/Ruby25/lib/ruby/gems/2.5.0
- C:/Users/irfan.sayed/.gem/ruby/2.5.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- C:\windows\system32
- C:\windows
- C:\windows\System32\Wbem
- C:\Program Files (x86)\Microsoft Application Virtualization Client
- C:\Program Files\PuTTY\
- C:\apache-maven-3.5.2-bin\apache-maven-3.5.2\bin
- "C:\Program Files\Java\jdk1.8.0_151\bin"
- C:\Program Files\Git\cmd
- C:\HashiCorp\Vagrant\bin
- C:\windows\System32\WindowsPowerShell\v1.0\
- C:\windows\System32\WindowsPowerShell\v1.0\
- C:\Ruby25\bin
- C:\Program Files\MySQL\MySQL Server 8.0\bin
- C:\Program Files\MongoDB\Server\4.0\bin
locally installed Gems are as follows :
activemodel (5.2.1, 4.2.10)
activerecord (5.2.1, 4.2.10)
activerecord-mysql2-adapter (0.0.3)
activesupport (5.2.1, 4.2.10)
arel (9.0.0, 6.0.4)
awesome_print (1.8.0)
backports (3.11.3)
bigdecimal (default: 1.3.4)
bson (1.12.5)
bson_ext (1.12.5)
builder (3.2.3)
bundler (1.16.3)
byebug (10.0.2)
cmath (default: 1.0.0)
coderay (1.1.2)
concurrent-ruby (1.0.5)
coolline (0.5.0)
csv (default: 1.0.0)
cucumber (3.1.2)
cucumber-core (3.2.0)
cucumber-expressions (6.0.1)
cucumber-tag_expressions (1.1.1)
cucumber-wire (0.0.1)
date (default: 1.0.0)
dbm (default: 1.0.0)
did_you_mean (1.2.0)
diff-lcs (1.3)
etc (default: 1.0.0)
fcntl (default: 1.0.0)
fiddle (default: 1.0.0)
fileutils (default: 1.0.2)
gdbm (default: 2.0.0)
gherkin (5.1.0)
highline (1.7.8)
i18n (0.9.5, 0.7.0)
io-console (default: 0.4.6)
ipaddr (default: 1.2.0)
jazz_fingers (5.0.0)
json (default: 2.1.0)
metaclass (0.0.4)
method_source (0.9.0)
minitest (5.11.3, 5.10.3)
mocha (1.6.0)
mongify (1.3.2)
mongo (1.12.5)
multi_json (1.13.1)
multi_test (0.1.2)
mysql (2.9.1 x86-mingw32)
mysql2 (0.5.2 x86-mingw32)
net-telnet (0.1.1)
openssl (default: 2.1.0)
pg (1.0.0 x86-mingw32)
power_assert (1.1.1)
pry (0.11.3)
pry-byebug (3.6.0)
pry-coolline (0.2.5)
psych (default: 3.0.2)
rake (12.3.1, 12.3.0, 11.3.0)
rdoc (default: 6.0.1)
rspec (2.99.0)
rspec-collection_matchers (1.1.3)
rspec-core (2.99.2)
rspec-expectations (2.99.2)
rspec-mocks (2.99.4)
scanf (default: 1.0.0)
sdbm (default: 1.0.0)
sqlite3 (1.3.13 x86-mingw32)
stringio (default: 0.0.1)
strscan (default: 1.0.0)
test-unit (3.2.7)
thread_safe (0.3.6)
tzinfo (1.2.5)
unicode_utils (1.4.0)
watchr (0.7)
webrick (default: 1.4.2)
xmlrpc (0.3.0)
yard (0.9.15)
zlib (default: 1.0.0)
bundle install and bundle update commands are just working fine. all the dependencies are gems are resolved properly and available in default folder of ruby.
database.config file used as below :
sql_connection do
adapter "mysql2"
host "localhost"
username "root"
password "<password>"
database "abc"
end
mongodb_connection do
host "localhost"
database "db"
end
however getting following error :
mongify check database.config
Traceback (most recent call last):
10: from C:/Ruby25/bin/mongify:23:in `<main>'
9: from C:/Ruby25/bin/mongify:23:in `load'
8: from C:/Ruby25/lib/ruby/gems/2.5.0/gems/mongify-1.3.2/bin/mongify:17
:in `<top (required)>'
7: from C:/Ruby25/lib/ruby/gems/2.5.0/gems/mongify-1.3.2/lib/mongify/cl
i/application.rb:28:in `execute!'
6: from C:/Ruby25/lib/ruby/gems/2.5.0/gems/mongify-1.3.2/lib/mongify/cl
i/command/worker.rb:68:in `execute'
5: from C:/Ruby25/lib/ruby/gems/2.5.0/gems/mongify-1.3.2/lib/mongify/cl
i/command/worker.rb:99:in `check_sql_connection'
4: from C:/Ruby25/lib/ruby/gems/2.5.0/gems/mongify-1.3.2/lib/mongify/da
tabase/sql_connection.rb:56:in `has_connection?'
3: from C:/Ruby25/lib/ruby/gems/2.5.0/gems/mongify-1.3.2/lib/mongify/da
tabase/sql_connection.rb:40:in `setup_connection_adapter'
2: from C:/Ruby25/lib/ruby/gems/2.5.0/gems/activerecord-4.2.10/lib/acti
ve_record/connection_handling.rb:50:in `establish_connection'
1: from C:/Ruby25/lib/ruby/gems/2.5.0/gems/activerecord-4.2.10/lib/acti
ve_record/connection_adapters/connection_specification.rb:174:in `spec'
C:/Ruby25/lib/ruby/gems/2.5.0/gems/activerecord-4.2.10/lib/active_record/connect
ion_adapters/connection_specification.rb:177:in `rescue in spec': Specified 'mys
ql2' 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). (G
em::LoadError)
not able to understand what is still missing. is the issue with MySQL adapter OR some version compatibility issue
EDIT : further update per suggestion from matthewd
i edited Gemfile and added following line
s.add_development_dependency('mysql2', '~> 0.4.10')
ran the bundle update --force , bundle install --force but it was still installing the 0.5.x version of mysql2 gem only
so i manually installed mysql2 gem of version 0.4.10 using following command
gem install mysql2 -v 0.4.10
but now it is giving following error
11: from C:/Ruby25/lib/ruby/gems/2.5.0/gems/mysql2-0.4.10-x86-mingw32/li
b/mysql2.rb:31:in `<top (required)>'
10: from C:/Ruby25/lib/ruby/gems/2.5.0/gems/activesupport-4.2.10/lib/act
ive_support/dependencies.rb:274:in `require'
9: from C:/Ruby25/lib/ruby/gems/2.5.0/gems/activesupport-4.2.10/lib/act
ive_support/dependencies.rb:240:in `load_dependency'
8: from C:/Ruby25/lib/ruby/gems/2.5.0/gems/activesupport-4.2.10/lib/act
ive_support/dependencies.rb:274:in `block in require'
7: from C:/Ruby25/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59
:in `require'
6: from C:/Ruby25/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59
:in `require'
5: from C:/Ruby25/lib/ruby/gems/2.5.0/gems/mysql2-0.4.10-x86-mingw32/li
b/mysql2/mysql2.rb:2:in `<top (required)>'
4: from C:/Ruby25/lib/ruby/gems/2.5.0/gems/activesupport-4.2.10/lib/act
ive_support/dependencies.rb:274:in `require'
3: from C:/Ruby25/lib/ruby/gems/2.5.0/gems/activesupport-4.2.10/lib/act
ive_support/dependencies.rb:240:in `load_dependency'
2: from C:/Ruby25/lib/ruby/gems/2.5.0/gems/activesupport-4.2.10/lib/act
ive_support/dependencies.rb:274:in `block in require'
1: from C:/Ruby25/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59
:in `require'
C:/Ruby25/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require': Co
uld not load 'active_record/connection_adapters/mysql2_adapter'. Make sure that
the adapter in config/database.yml is valid. If you use an adapter other than 'm
ysql', 'mysql2', 'postgresql' or 'sqlite3' add the necessary adapter gem to the
Gemfile. (LoadError)
The error message is misleading: you're using a version of the mysql2 gem that's too new for Active Record 4.2.10 (the latest version mongify supports).
The simplest solution is to explicitly use an older version of mysql2 by including a version constraint in your Gemfile entry:
gem "mysql2", "< 0.5"
Finally it is resolved. it has the issue with ruby version and 32 bit libraries. ruby 2.3 was properly tested and works fine with mongify gem. i was using latest version of ruby and was the issue.

Installed mysql gem file and received error 'wrong number of arguments (4 for 0) (ArgumentError)'

I am trying to run the following ruby program
require 'rubygems'
require 'mysql'
db = Mysql.new('local','root','','')
st_qry = db.query("SELECT * FROM `notification` ORDER BY notification_id DESC ")
puts ("There were #{st_qry.num_rows} rows returned.")
When I execute this code through terminal I get the following error message:
joe.fleck$ ruby mysql_req.rb
mysql_req.rb:4:in `initialize': wrong number of arguments (4 for 0) (ArgumentError)
from mysql_req.rb:4:in `new'
from mysql_req.rb:4
I have no idea how to fix this. I had to install mysql by this command:
sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- \
--with-mysql-dir=/usr/local/mysql --with-mysql-lib=/usr/local/mysql/lib \
--with-mysql-include=/usr/local/mysql/include
because the ordinary command (sudo gem install mysql) would error and not install.
I have also tried uninstall and install mysql. I tried mysql2 and it errors out when I try to execute the program.
Does anyone know how to solve this?
MacBook Pro, OS X version 10.8.2
$ gem list
*** LOCAL GEMS ***
addressable (2.3.2)
builder (3.1.3)
childprocess (0.3.5)
cucumber (1.2.1)
diff-lcs (1.1.3)
fastercsv (1.5.5)
ffi (1.1.5)
gherkin (2.11.3)
json (1.7.5)
libwebsocket (0.1.5)
multi_json (1.3.6)
mysql (2.8.1)
pkg-config (1.1.4)
rb-appscript (0.6.1)
rubygems-update (1.8.24)
rubyzip (0.9.9)
safariwatir (0.4.0)
selenium-webdriver (2.25.0)
shoes (3.0.1)
watir-webdriver (0.6.1)

Rails 3 - Incorrect MySQL client library version! Gem compiled for the wrong client library version

I cloned the github repo https://github.com/8bitpal/hackful, run 'bundle install' and now 'rake db:create'. But I get an error message:
Incorrect MySQL client library version! This gem was compiled for 5.0.45 but the client library is 5.5.15.
Tried to find out more infos about my mysql setup:
$ mysql_config --version
$ 5.0.45
$ mysql
$ mysql> SELECT version();
+-----------+
| version() |
+-----------+
| 5.1.57 |
+-----------+
Since I rarely do sysadmin stuff I feel a bit lost how to interpretate this info, i.e. why is the "client library 5.5.15" mentioned, is that kind of a minimum version mysql version when using the mysql2 gem?
Anyhow, I did some more research on SO and found this thread
Ruby mysql2 gem compiled for wrong mysql client library version. The question is similar to mine:
After updating MySQL to 5.5 using apt-get, the mysql2 gem stopped
working.
Here's the error:
Incorrect MySQL client library version! This gem was compiled for
5.5.17 but the client library is 5.1.58. (RuntimeError)
The answer in that thread:
I have encounter the same error when using Ubuntu Server 11.04 and
Percona Server, what have I done was:
replace /usr/lib/libmysqlclient.so.16.0.0 with
/usr/lib/libmysqlclient.so.18.0.0
Problem in my case is that I don't have such a file:
ls /usr/lib/mysql
libdbug.a libmyisam.a libmysqlclient.a libmysqlclient_r.a libmystrings.a libvio.a
libheap.a libmyisammrg.a libmysqlclient.la libmysqlclient_r.la libmysys.a
Most other threads with a similar topic are about Windows, but I'm on OS X. Any ideas what can I try next? More infos about my setup: OS X Lion, rvm, Rails 3.1.3, ruby 1.9.2p290. Gem list:
*** LOCAL GEMS ***
actionmailer (3.1.3)
actionpack (3.1.3)
activemodel (3.1.3)
activerecord (3.1.3)
activeresource (3.1.3)
activesupport (3.1.3)
addressable (2.2.7)
arel (2.2.1)
bcrypt-ruby (3.0.1)
builder (3.0.0)
bundler (1.0.21)
cancan (1.6.5)
capybara (1.1.2)
capybara-webkit (0.10.1)
childprocess (0.3.0)
coderay (1.0.5)
coffee-rails (3.1.1)
coffee-script (2.2.0)
coffee-script-source (1.2.0)
cucumber (1.1.4)
cucumber-rails (1.2.1)
database_cleaner (0.7.1)
delayed_job (3.0.0)
delayed_job_active_record (0.3.1)
devise (2.0.0)
diff-lcs (1.1.3)
erubis (2.7.0)
execjs (1.3.0)
factory_girl (2.6.3)
factory_girl_rails (1.7.0)
faker (1.0.1)
fakeweb (1.3.0)
ffi (1.0.11)
fileutils (0.7)
gherkin (2.7.6)
growl (1.0.3)
guard (1.0.3)
guard-bundler (0.1.3)
guard-cucumber (0.7.5)
guard-rspec (0.7.2)
guard-spork (0.8.0)
hike (1.2.1)
i18n (0.6.0)
jquery-rails (1.0.19)
json (1.6.5)
launchy (2.0.5)
libv8 (3.3.10.4 x86_64-darwin-11)
mail (2.3.0)
make_voteable (0.1.1)
method_source (0.7.1)
mime-types (1.17.2)
multi_json (1.0.4)
mysql (2.8.1)
mysql2 (0.3.11)
nokogiri (1.5.0)
orm_adapter (0.0.6)
polyglot (0.3.3)
pry (0.9.8.4)
rack (1.3.6)
rack-cache (1.1)
rack-mount (0.8.3)
rack-ssl (1.3.2)
rack-test (0.6.1)
rails (3.1.3)
rails_autolink (1.0.5)
railties (3.1.3)
rake (0.9.2.2)
rb-fsevent (0.9.1)
rdiscount (1.6.8)
rdoc (3.12)
rest-client (1.6.7)
rmagick (2.13.1)
rspec (2.8.0)
rspec-core (2.8.0)
rspec-expectations (2.8.0)
rspec-mocks (2.8.0)
rspec-rails (2.8.1)
rubyzip (0.9.5)
sass (3.1.12)
sass-rails (3.1.5)
selenium-webdriver (2.18.0)
slop (2.4.4)
spork (0.9.2)
sprockets (2.0.3)
sqlite3 (1.3.5)
term-ansicolor (1.0.7)
therubyracer (0.9.9)
thor (0.14.6)
tilt (1.3.3)
treetop (1.4.10)
tzinfo (0.3.31)
uglifier (1.2.2)
warden (1.1.0)
xpath (0.1.4)
Update
I checked what homebrew installed for mysql. When I understood it correct, this should be the mysql client library version:
$ ls /usr/local/Cellar/mysql
$ 5.5.15
Now I need to get the mysql_config updated to 5.5.15?
Update 2
Solved. This one did the trick:
gem install mysql2 -- --with-mysql-config=/usr/local/Cellar/mysql/5.5.15/bin/mysql_config
Source: Install the mysql2 gem for a specific mysql client version?
Had this problem after upgrading packages in homebrew. The mysql2 gem simply needs to be told to re-compile its non-ruby components.
Assuming homebrew is set up correctly, the following should fix the problem:
gem uninstall mysql2
gem install mysql2 # or bundle install
(depending on your bundler config, you may need to do something more complicated, but this was enough for me)
I have solved the problem based on this tutorial, which helped me installing the correct version of mysql for rails
http://blog.mmediasys.com/2011/07/07/installing-mysql-on-windows-7-x64-and-using-ruby-with-it/

JRuby, Rails 2.3.5, MySQL Databases not being created with rake db:create:all

Basic information:
Ruby version : 1.8.7
JRuby version: 1.5.3
Rails version: 2.3.5
Mysql version: Ver 14.14 Distrib 5.1.48, for apple-darwin10.3.0 (i386) using readline 5.1
I've been having a hell of a time trying to get JRuby, Rails, and MySQL to play nicely together. I've come to a dead end and now need some help.
I have installed what I believe to be the correct gems to allow JRoR to talk with MySQL. The list of gems I have installed are below. How I am trying to create a JRoR + MySQL app is like so:
$ jruby -S rails -d mysql app_name
$ cd app_name
Open up Textmate and configure config/database.yml by changing all adapters from "mysql" to "jdbcmysql".
Back in Terminal:
$ jruby -S script/generate scaffold post title:string content:text
$ rake db:create:all
At this point, rake doesn't spit out anything to tell me the databases were created. Here's the result of trying to run my migration:
$ rake db:migrate
rake aborted!
The driver encountered an unknown error: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown database 'app_name_development'
I have no idea what I'm doing wrong and would greatly appreciate help.
Here's my current gem list:
$ jruby -S gem list
* LOCAL GEMS *
abstract (1.0.0)
actionmailer (3.0.0, 2.3.5)
actionpack (3.0.0, 2.3.5)
activemodel (3.0.0)
activerecord (3.0.0, 2.3.5)
activerecord-jdbc-adapter (1.0.2, 0.9.7)
activerecord-jdbcmysql-adapter (1.0.2, 0.9.7)
activerecord-jdbcsqlite3-adapter (0.9.7)
activeresource (3.0.0, 2.3.5)
activesupport (3.0.0, 2.3.10, 2.3.5)
after_commit (1.0.8)
arel (1.0.1)
bouncy-castle-java (1.5.0145.2)
builder (2.1.2)
bundler (1.0.2)
columnize (0.3.1)
erubis (2.6.6)
gem_plugin (0.2.3)
i18n (0.4.1)
jdbc-mysql (5.0.4)
jdbc-sqlite3 (3.6.3.054)
jruby-jars (1.5.3)
jruby-openssl (0.7.2)
jruby-rack (1.0.3)
mail (2.2.7)
mime-types (1.16)
mongrel (1.1.5)
polyglot (0.3.1)
rack (1.2.1, 1.0.1)
rack-mount (0.6.13)
rack-test (0.5.6)
rails (2.3.5)
railties (3.0.0)
rake (0.8.7)
riddle (1.1.0)
rspec (1.3.0)
ruby-debug (0.10.3)
ruby-debug-base (0.10.3.2)
rubyzip (0.9.4)
sources (0.0.1)
thinking-sphinx (1.3.20)
thor (0.14.3)
treetop (1.4.8)
tzinfo (0.3.23)
warbler (1.2.1)
will_paginate (2.3.15)
You shouldn't need to change the database name to jdbcmysql. In fact, doing this defeats db:create(:all).
http://jruby-extras.rubyforge.org/activerecord-jdbc-adapter/
I noticed the "Unknown database 'app_name_development'" error. Is app_name_development really the name of your database in database.yml? Just checking, because if not, that would be very interesting.
I assume you're not connecting to MySQL with the root account. If that's true, does the user you are connecting with have permissions to create the database app_name_development? By default, only root can create databases. You can grant your user permission with something like this:
GRANT CREATE on app_name_development.* to 'user'#'host';