Mac Brew Mysql Issue

  • ERROR 1524 (HY000): Plugin 'mysql_native_password' is not loaded

https://github.com/Homebrew/homebrew-core/issues/180498

MySQL 9 不再支持 mysql_native_password 认证方法,这可能会影响从 MySQL 8.x 升级到 MySQL 9 的用户。为了解决此问题,您需要更新 MySQL 用户表,使用新的认证方法。按照以下步骤操作:

1.- 禁用权限表:
编辑 MySQL 配置文件,通常位于 /opt/homebrew/etc/my.cnf。在 [mysqld] 部分下添加以下行以禁用权限表:

[mysqld]
skip-grant-tables

2.- 重启 MySQL:
使用 Homebrew 重启 MySQL:

brew services restart mysql

3.- 以 root 用户连接 MySQL:

mysql -uroot

4.- 更新用户认证方法:
刷新权限:

FLUSH PRIVILEGES;

5.- 检查使用 mysql_native_password 插件的用户:

SELECT User, Host, plugin FROM mysql.user WHERE plugin = 'mysql_native_password';

6.- 将 root 用户更新为使用 caching_sha2_password 插件:

ALTER USER 'root'@'localhost' IDENTIFIED WITH caching_sha2_password BY 'new_password';

7.- 重新启用权限表:
更新后,删除或注释掉 MySQL 配置文件中的 skip-grant-tables 行。

8.- 重启 MySQL 以应用更改:

brew services restart mysql

通过执行这些步骤,您应该能够在升级到 MySQL 9 后解决认证方法问题。

  • err_mysqlConnect: Error: ER_NOT_SUPPORTED_AUTH_MODE: Client does not support authentication protocol requested by server; consider upgrading MySQL client

https://stackoverflow.com/questions/50093144/mysql-8-0-client-does-not-support-authentication-protocol-requested-by-server

使用 npm 安装 mysql2:
https://github.com/sidorares/node-mysql2

Avatar photo

作者: erishen

前端工程师 React, React Native, Taro, Node.js, Next.js, Express, Nest.js, PHP, Java / Spring Boot, Python, Go, Rust ...

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注