1

When I run rails db:schema:dump I receive this error

rails aborted!
LoadError: libmysqlclient.so.20: cannot open shared object file: No such file or directory - /home/mekjaaganu/.rvm/gems/ruby-2.3.3/gems/mysql2-0.4.5/lib/mysql2/mysql2.so
/home/mekjaaganu/.rvm/gems/ruby-2.3.3/gems/mysql2-0.4.5/lib/mysql2.rb:31:in `require'
/home/mekjaaganu/.rvm/gems/ruby-2.3.3/gems/mysql2-0.4.5/lib/mysql2.rb:31:in `<top (required)>'
/home/mekjaaganu/.rvm/gems/ruby-2.3.3/gems/bundler-1.14.3/lib/bundler/runtime.rb:91:in `require'
/home/mekjaaganu/.rvm/gems/ruby-2.3.3/gems/bundler-1.14.3/lib/bundler/runtime.rb:91:in `block (2 levels) in require'
/home/mekjaaganu/.rvm/gems/ruby-2.3.3/gems/bundler-1.14.3/lib/bundler/runtime.rb:86:in `each'
/home/mekjaaganu/.rvm/gems/ruby-2.3.3/gems/bundler-1.14.3/lib/bundler/runtime.rb:86:in `block in require'
/home/mekjaaganu/.rvm/gems/ruby-2.3.3/gems/bundler-1.14.3/lib/bundler/runtime.rb:75:in `each'
/home/mekjaaganu/.rvm/gems/ruby-2.3.3/gems/bundler-1.14.3/lib/bundler/runtime.rb:75:in `require'
/home/mekjaaganu/.rvm/gems/ruby-2.3.3/gems/bundler-1.14.3/lib/bundler.rb:107:in `require'
/home/mekjaaganu/Sites/simple_cms/config/application.rb:7:in `<top (required)>'
/home/mekjaaganu/Sites/simple_cms/Rakefile:4:in `require_relative'
/home/mekjaaganu/Sites/simple_cms/Rakefile:4:in `<top (required)>'
/home/mekjaaganu/.rvm/gems/ruby-2.3.3/gems/railties-5.0.1/lib/rails/commands/rake_proxy.rb:13:in `block in run_rake_task'
/home/mekjaaganu/.rvm/gems/ruby-2.3.3/gems/railties-5.0.1/lib/rails/commands/rake_proxy.rb:11:in `run_rake_task'
/home/mekjaaganu/.rvm/gems/ruby-2.3.3/gems/railties-5.0.1/lib/rails/commands/commands_tasks.rb:51:in `run_command!'
/home/mekjaaganu/.rvm/gems/ruby-2.3.3/gems/railties-5.0.1/lib/rails/commands.rb:18:in `<top (required)>'
/home/mekjaaganu/Sites/simple_cms/bin/rails:9:in `require'
/home/mekjaaganu/Sites/simple_cms/bin/rails:9:in `<top (required)>'
/home/mekjaaganu/.rvm/gems/ruby-2.3.3/gems/spring-2.0.1/lib/spring/client/rails.rb:28:in `load'
/home/mekjaaganu/.rvm/gems/ruby-2.3.3/gems/spring-2.0.1/lib/spring/client/rails.rb:28:in `call'
/home/mekjaaganu/.rvm/gems/ruby-2.3.3/gems/spring-2.0.1/lib/spring/client/command.rb:7:in `call'
/home/mekjaaganu/.rvm/gems/ruby-2.3.3/gems/spring-2.0.1/lib/spring/client.rb:30:in `run'
/home/mekjaaganu/.rvm/gems/ruby-2.3.3/gems/spring-2.0.1/bin/spring:49:in `<top (required)>'
/home/mekjaaganu/.rvm/gems/ruby-2.3.3/gems/spring-2.0.1/lib/spring/binstub.rb:31:in `load'
/home/mekjaaganu/.rvm/gems/ruby-2.3.3/gems/spring-2.0.1/lib/spring/binstub.rb:31:in `<top (required)>'
/home/mekjaaganu/Sites/simple_cms/bin/spring:15:in `require'
/home/mekjaaganu/Sites/simple_cms/bin/spring:15:in `<top (required)>'
bin/rails:3:in `load'
bin/rails:3:in `<main>'
(See full trace by running task with --trace)

My config/database.yml file looks like this. Already checked the database name and user password. Everything looks fine. Able to create database name simple_cms_development and password is right.

# MySQL. Versions 5.0 and up are supported.
#
# Install the MySQL driver
#   gem install mysql2
#
# Ensure the MySQL gem is defined in your Gemfile
#   gem 'mysql2'
#
# And be sure to use new-style password hashing:
#   http://dev.mysql.com/doc/refman/5.7/en/old-client.html
#
default: &default
  adapter: mysql2
  encoding: utf8
  pool: 5
  username: rails_user
  password: secretpassword
  socket: /var/run/mysqld/mysqld.sock

development:
  <<: *default
  database: simple_cms_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: simple_cms_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: simple_cms_production
  username: simple_cms
  password: <%= ENV['SIMPLE_CMS_DATABASE_PASSWORD'] %>
Holger Just
  • 52,918
  • 14
  • 115
  • 123
Haziq Azmi
  • 49
  • 1
  • 8
  • please check this link http://stackoverflow.com/questions/8456300/mysql2-so-libmysqlclient-r-so-15-cannot-open-shared-object-file-no-such-file#10369022 – Chaudhary Prakash Feb 08 '17 at 07:08

1 Answers1

0

You might be missing development libraries in your machine. Install this library if you dont already have it.

sudo apt-get install libmysqlclient20-dev
titan
  • 664
  • 6
  • 18
  • This is not correct. The OP just typed the wrong command, using `rails` instead of `rake`. – Ed de Almeida Feb 08 '17 at 07:00
  • @EddeAlmeida OP might be developing in `rails5`. See this http://blog.bigbinary.com/2016/01/14/rails-5-supports-rake-commands-using-rails.html – titan Feb 08 '17 at 07:02
  • should work without it. Being on safe side do all steps again :). And please upvote my answer. Thanks – titan Feb 08 '17 at 07:20
  • tqvm.. actually, i did what you told me to insert 'sudo apt-get install libmysqlclient20-dev.' but i'm getting an error where it couldn't locate the package... so what i do is insert 'sudo apt-get update' and then 'sudo apt-get install libmysqlclient-dev' – Haziq Azmi Feb 08 '17 at 07:24