'symbol not found in flat namespace '_mysql_affected_rows' in mac m1

i have a problem when i did

bundle exec rails db:migrate

Any ideas on how to fix it? I have no idea why _mysql_affected_rows is not found. Help would be appreciated.

rails aborted!
LoadError: dlopen(/Users/myname/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/mysql2-0.5.4/lib/mysql2/mysql2.bundle, 0x0009): symbol not found in flat namespace '_mysql_affected_rows' - /Users/myname/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/mysql2-0.5.4/lib/mysql2/mysql2.bundle
/Users/myname/Desktop/github/company/config/application.rb:9:in `<top (required)>'
/Users/myname/Desktop/github/company/Rakefile:4:in `require_relative'
/Users/myname/Desktop/github/company/Rakefile:4:in `<top (required)>'
bin/rails:4:in `<main>'
(See full trace by running task with --trace)


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source