首页 > 解决方案 > 如何使用 mysql@5.6 修复“无法加载身份验证插件'caching_sha2_password'”

问题描述

数据库创建失败并Authentication plugin 'caching_sha2_password' cannot be loaded出现错误。

当我运行以下命令时发生上述错误:

$ RAILS_ENV=test rake db:create

错误信息:

Authentication plugin 'caching_sha2_password' cannot be loaded: dlopen(/usr/local/Cellar/mysql@5.6/5.6.46/lib/plugin/caching_sha2_password.so, 2): image not found
Couldn't create database for {"adapter"=>"mysql2", "encoding"=>"utf8", "reconnect"=>true, "pool"=>5, "socket"=>"/tmp/mysql.sock", "username"=>"root", "password"=>nil, "database"=>"ht_test"}, charset: utf8, collation: utf8_unicode_ci
(if you set the charset manually, make sure you have a matching collation)

我知道其他开发人员对 mysql@8.* 也有类似的问题。这就是为什么我切换到mysql@5.6. 我仍然面临这个问题。

请提出可能的解决方案。

谢谢

标签: ruby-on-railsruby

解决方案


尝试使用它,它对我有用

ALTER USER 'yourusername'@'localhost' 
IDENTIFIED WITH mysql_native_password BY 'youpassword';

推荐阅读