When I tried to create a database with rails db:create
, I received the following error:
Could not find mysql2-0.5.4 in any of the sources
Run `bundle install` to install missing gems.
Are you going to set mysql v5.4?
If you search brew search mysql
to find the corresponding homebrews, you will find the following:
automysqlbackup [email protected]@5.6
mysql✔[email protected]✔
mysql++mysql-sandbox mysqltuner
mysql-client mysql-search-replace qt-mysql
The current situation is as follows.I can't find version 5.4 of mysql, so please take care of me
brew search [email protected]
=>Formulae
[email protected] ✔ [email protected]
Additional
I did bundle install
and bundle update
.
Docker-related files are as follows:
docker-compose.yml
version:"3"
volumes:
data:
services:
web:
build:.
ports:
- "3000:3000"
volumes:
- ".:/ rails-docker-mysql"
environment:
- "DATABASE_PASSWORD=password"
tty —true
stdin_open —true
depend_on:
- db
links:
- db
db:
image:mysql:5.7
volumes:
- "data:/var/lib/mysql"
environment:
MYSQL_ROOT_PASSWORD:password
ports:
- "3306:3306"
database.yml
default:&default
adapter —mysql2
encoding —utf8
pool:<%=ENV.fetch("RAILS_MAX_THREADS"){5}%>
host —db
user:root
port —3306
password:<%=ENV.fetch("DATABASE_PASSWORD")%>
development:
<<:* default
database —rails_docker_mysql_development
test:
<<:* default
database —rails_docker_mysql_test
production:
<<:* default
database —rails_docker_mysql_production
username —rails_docker_mysql
password:<%=ENV['RAILS_DOCKER_MYSQL_DATABASE_PASSWORD']%>
Mysql2gem version 0.5.4 is missing error.Homebrew is irrelevant.
Since bundle install
has been done, if you do bundle exec rails db:create
, the error will not appear.
© 2024 OneMinuteCode. All rights reserved.