0
0

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.

あともう少し。MySQLサービス起動後、Railsサーバが起動しない3

Last updated at Posted at 2020-06-02

発生した背景

MySQLサービスが復旧したところで、Railsを起動すると以下のエラーが発生した。

/Users/ichikawadaisuke/projects/krown/vendor/ruby/2.5.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require': dlopen(/Users/ichikawadaisuke/projects/krown/vendor/ruby/2.5.0/gems/mysql2-0.5.2/lib/mysql2/mysql2.bundle, 9): Library not loaded: /usr/local/opt/mysql/lib/libmysqlclient.21.dylib (LoadError)
  Referenced from: /Users/ichikawadaisuke/projects/krown/vendor/ruby/2.5.0/gems/mysql2-0.5.2/lib/mysql2/mysql2.bundle
  Reason: image not found - /Users/ichikawadaisuke/projects/krown/vendor/ruby/2.5.0/gems/mysql2-0.5.2/lib/mysql2/mysql2.bundle

対応手順

MySQLサービスを再インストールしたため、既存のGemが動作しなくなったと判断。
Gemの再セッティングを実施する。
①以下コマンドにて原因を多角的に調査する

$ bundle update
$ rails s
(これで復旧するかを試してみるも、Railsサーバは起動しなかった)
$ bundle doctor
(MySQLに紐つくような目立ったエラーは発生していない)

②以下のコマンドでGemを入れ替える

$ bundle exec gem uninstall mysql2
Successfully uninstalled mysql2-0.5.2
$ bundle install --path vendor
(同コマンドで改めてGemを入れなおす)

③やっと…Railsが起動した…

Use Ctrl-C to stop
Started GET "/" for ::1 at 2020-06-02 18:46:42 +0900
ActiveRecord::NoDatabaseError (Unknown database 'krown_development'):

④あとはお決まりのコマンドを実行して、無事終了しました😆

$ bundle exec rake db:create
$ bundle exec rake db:migrate
0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?