Help us understand the problem. What is going on with this article?

#エラー解消 RailsでMySQL bundle install エラー

RailsでMySQLを使ってみた時に出たエラー

DBの指定はrails new時点で、DBをデフォルトのSQLiteからMySQLに指定することが可能ですがしていなかったので、
途中からDBをMySQLに指定しようとしたら出たエラーです。

したこと

Gemfileに gem 'mysql2'と記述し、bundle installをした。

エラー

bundle install後にエラー

エラーメッセージ
Gem files will remain installed in
/Users/*ユーザー名*/*ペアレントディレクトリ名*/*カレントディレクトリ名*/vendor/bundle/ruby/2.5.0/gems/mysql2-0.5.2 for inspection.
Results logged to
/Users/*ユーザー名*/*ペアレントディレクトリ名*/*カレントディレクトリ名*/vendor/bundle/ruby/2.5.0/extensions/x86_64-darwin-18/2.5.0-static/mysql2-0.5.2/gem_make.out

An error occurred while installing mysql2 (0.5.2), and Bundler cannot continue.
Make sure that `gem install mysql2 -v '0.5.2' --source 'https://rubygems.org/'` succeeds before bundling.

解決コマンド

bundle config --local build.mysql2 --with-opt-lib=/usr/local/opt/openssl/lib --with-opt-include=-I/usr/local/opt/openssl/include
bundle config build.mysql2 --with-opt-lib=/usr/local/opt/openssl/lib --with-opt-include=-I/usr/local/opt/openssl/include

2つともしてください。

もう一回

Gemfileにgem 'mysql2'と記述し、bundle install --path vendor/bundle

メッセージ
Installing mysql2 0.5.2 with native extensions
Bundle complete! 19 Gemfile dependencies, 79 gems now installed.
Gems in the group production were not installed.
Bundled gems are installed into `./vendor/bundle`

解決〜!!
Qiita記事の方に感謝。

参考にした記事

Why do not you register as a user and use Qiita more conveniently?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away