3
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

libmysqlclient.so.18: cannot open shared object file: No such file or directoryの解決法

Posted at

問題

本番環境の自分のアプリのディレクトリで rake db:create RAILS_ENV=production したら
以下のエラーが表示された。

エラー

libmysqlclient.so.18: cannot open shared object file: No such file or directory

解決手順

① mysql2というgemをアンインストール

$ gem uninstall mysql2

② mysql2というgemをインストール

$ gem install mysql2

以下のエラーが出る。

ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.

解決方法を提示してくれる。

mysql client is missing. You may need to 'sudo apt-get install libmariadb-dev', 'sudo apt-get install libmysqlclient-dev' or 'sudo yum install mysql-devel', and try again.

③ mysql-develをインストール

sudo yum install mysql-devel

ここまでやって rake db:create RAILS_ENV=production すると、「bundle installして」と言われる。

Could not find mysql2-0.5.3 in any of the sources
Run `bundle install` to install missing gems.

④ bundle install

言われたとおりbundle installしたら、今度こそ rake db:create RAILS_ENV=production できました🎉

参考記事

MySQLのバージョンを5.1から5.7にしてRubyからMySQLに接続する際にlibmysqlclient_r.so.16: cannot open shared object file: No such file or directory

3
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?