Friday, June 02, 2017

Gem Load Error is: uninitialized constant Mysql2::Client::SECURE_CONNECTION on Ubuntu 16.04

While I am trying to create DB with rake db:create then I am getting this error:

rake aborted!
Bundler::GemRequireError: There was an error while trying to load the gem 'mysql2'.
Gem Load Error is: uninitialized constant Mysql2::Client::SECURE_CONNECTION
Backtrace for gem load error is:
/home/sachin/.rvm/gems/ruby-1.9.3-p545@oomph-sachin/gems/mysql2-0.3.16/lib/mysql2/client.rb:12:in `<class:Client>'
/home/sachin/.rvm/gems/ruby-1.9.3-p545@oomph-sachin/gems/mysql2-0.3.16/lib/mysql2/client.rb:2:in `<module:Mysql2>'
/home/sachin/.rvm/gems/ruby-1.9.3-p545@oomph-sachin/gems/mysql2-0.3.16/lib/mysql2/client.rb:1:in `<top (required)>'
/home/sachin/.rvm/gems/ruby-1.9.3-p545@oomph-sachin/gems/mysql2-0.3.16/lib/mysql2.rb:10:in `require'
/home/sachin/.rvm/gems/ruby-1.9.3-p545@oomph-sachin/gems/mysql2-0.3.16/lib/mysql2.rb:10:in `<top (required)>'
/home/sachin/.rvm/gems/ruby-1.9.3-p545@oomph-sachin/gems/bundler-1.15.1/lib/bundler/runtime.rb:82:in `require'
/home/sachin/.rvm/gems/ruby-1.9.3-p545@oomph-sachin/gems/bundler-1.15.1/lib/bundler/runtime.rb:82:in `block (2 levels) in require'
/home/sachin/.rvm/gems/ruby-1.9.3-p545@oomph-sachin/gems/bundler-1.15.1/lib/bundler/runtime.rb:77:in `each'
/home/sachin/.rvm/gems/ruby-1.9.3-p545@oomph-sachin/gems/bundler-1.15.1/lib/bundler/runtime.rb:77:in `block in require'
/home/sachin/.rvm/gems/ruby-1.9.3-p545@oomph-sachin/gems/bundler-1.15.1/lib/bundler/runtime.rb:66:in `each'
/home/sachin/.rvm/gems/ruby-1.9.3-p545@oomph-sachin/gems/bundler-1.15.1/lib/bundler/runtime.rb:66:in `require'
/home/sachin/.rvm/gems/ruby-1.9.3-p545@oomph-sachin/gems/bundler-1.15.1/lib/bundler.rb:108:in `require'
/home/sachin/rails_projects/sachin/config/application.rb:8:in `<top (required)>'


Solution:

Update your Gemfile to version 0.3.20

     gem 'mysql2', '~> 0.3.20'

Then run "bundle update mysql2" and then try it will work!


Reactions:

1 comment:

  1. Thanks for sharing the best information and suggestions, If you are looking for the best Shopify Development, then visit ARRJ Microsystems Pvt. Ltd. Highly energetic blog, I’d love to find out some additional information.

    ReplyDelete