[Ruby] For those who want to use MySQL as a database in the environment construction of Rails6 ~.

1 minute read

In the first place, MySQL and mysql2 are different things

You know MySQL is a database, mysql2 is a Rails-specific gem**, and is interpreted as a bridge that connects the database and Rails.

About mysql2 error

$ bundle install --path vendor/bundle

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

$ gem install mysql2 -v '0.5.3'

ERROR: While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions for the /Library/Ruby/Gems/2.3.0 directory.

And even if you do a bundle install, you become a resident of the infinite loop, saying “Oh, don’t go near me!!”.

I was also a resident there, but please be relieved, you can escape lol

Solution###

**Conclusion, all you have to do is never install mysql2. **

Here are the familiar Gemfile and Gemfile.lock.

Gemfile, if you say, when you go to buy the game software, “** What to buy list ”, Gemfile.lock is a “receipt**”.

When I do bundle install, I see the software on this list of things to buy and install the gem. Now, the cause of the error is “**Is the game software on the receipt going to buy again?”

Except for those who are playing, watching, or storing game software, but lol That is nice.

So let’s buy the new series version again just because we never bought it. Is a story. However, there are two things to do.

$ gem uninstall mysql2

Gemfile.lock


Delete the one named mysql2

Then buy it again!

$ bundle install --path vendor/bundle