Search code examples
ruby-on-railsrubyunicornmysql2

mysql2 gem not working after updating to Ubuntu 16.04 - libmysqlclient.so.18


Everything worked fine prior to the update. Using ruby 1.9.3p392 with RVM with rails (3.2.12) Using MySQL 5.7.16 and Nginx and Unicorn

Log shows

LoadError: libmysqlclient.so.18: cannot open shared object file: No such file or directory - /home/bill/apps/xxx/shared/bundle/ruby/1.9.1/gems/mysql2-0.3.16/lib/mysql2/mysql2.so

I tried:

  1. uninstall/install mysql2 gem
  2. Running bundle install

Nothing worked. Anyone had that problem after updating ?


Solution

  • Remove and reinstall mysql2 gem.

    I had the same thing. Upgraded from Ubuntu 14 to 16 and saw this same error.

    To fix it, I just uninstalled the mysql2 gem and reinstalled it using bundler.

    1. Uninstall mysql2 gem:

      $ bundle exec gem uninstall mysql2
      
    2. Reinstall mysql2 gem:

      $ bundle install
      

    The reason is because it has to install native extensions when it installs the gem, and a large system change like upgrading the OS 1 or more versions requires rebuilding those native extensions.

    Hope that helps.