

`rails db:migrate` を実行すると以下のエラーが発生します。

[code]

    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)
    
[/code]

以下はdatabase.ymlです

[code]

    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'] %>
    
[/code]

以下言語のバージョンです。

・Ruby (3.0.1)  
・Ruby on Rails (6.1.3.2)  
・MySQL (8.0.25)

このエラーの原因と解決策を教えてくださると助かります。  
よろしくお願いします。


CC BY-SA 4.0
2021-06-15T07:44:57.287
77573
2021-06-16T00:39:52.903
2021-06-16T00:39:52.903
3060
46861
question
ruby-on-rails mysql
rails db:migrate をすると「Mysql2::Error: The user specified as a definer」というエラー