rails db:migrate
を実行すると以下のエラーが発生します。
rails aborted!
ActiveRecord::StatementInvalid: Mysql2::Error: The user specified as a definer ('mysql.infoschema'@'localhost') does not exist
/Users/yuzuki/environment/yuzuki_app/bin/rails:5:in `<top (required)>'
/Users/yuzuki/environment/yuzuki_app/bin/spring:10:in `require'
/Users/yuzuki/environment/yuzuki_app/bin/spring:10:in `block in <top (required)>'
/Users/yuzuki/environment/yuzuki_app/bin/spring:7:in `<top (required)>'
Caused by:
Mysql2::Error: The user specified as a definer ('mysql.infoschema'@'localhost') does not exist
/Users/yuzuki/environment/yuzuki_app/bin/rails:5:in `<top (required)>'
/Users/yuzuki/environment/yuzuki_app/bin/spring:10:in `require'
/Users/yuzuki/environment/yuzuki_app/bin/spring:10:in `block in <top (required)>'
/Users/yuzuki/environment/yuzuki_app/bin/spring:7:in `<top (required)>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
以下はdatabase.ymlです
default: &default
adapter: mysql2
encoding: utf8mb4
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
username: root
password: Yuzuki_1201
host: localhost
development:
<<: *default
database: yuzuki_app_development
test:
<<: *default
database: yuzuki_app_test
production:
<<: *default
database: yuzuki_app_production
username: <%= ENV['DB_USERNAME'] %>
password: <%= ENV['DB_PASSWORD'] %>
以下言語のバージョンです。
・Ruby (3.0.1)
・Ruby on Rails (6.1.3.2)
・MySQL (8.0.25)
このエラーの原因と解決策を教えてくださると助かります。
よろしくお願いします。
mysql -u root -p mysql> SET GLOBAL innodb_fast_shutdown = 1; mysql_upgrade -u root -p
を実行しましたが、3行目で次のエラーが発生しました。The mysql_upgrade client is now deprecated. The actions executed by the upgrade client are now done by the server. To upgrade, please start the new MySQL binary with the older data directory. Repairing user tables is done automatically. Restart is not required after upgrade.
日本語翻訳してみましたが、古いディレクトリ、mysqlバイナリがわからず解決に至りませんでした。