MySQL 8.0 默认创建的用户密码加密方式为:caching_sha2_password,有些应用在连接时由于不兼容会导致报错,可以修改为 MySQL 5 使用的加密方式:sha256_password。
创建用户:
create user "newuser"@"localhost" identified by "PASSWORD";
授予全部数据库权限:
grant all privileges on *.* to 'newuser'@'localhost';
修改成原来的加密方式:
alter user "newuser"@"localhost" identified with mysql_native_password by 'PASSWORD';
刷新权限:
FLUSH PRIVILEGES;
查看已建立的用户及加密方式:
SELECT user,authentication_string,plugin,host FROM mysql.user;
显示如下:
+------------------+------------------------------------------------------------------------+---
| user | authentication_string | plugin | host |
+------------------+------------------------------------------------------------------------+-----
| marco | *D51541FCBC8DD8E | mysql_native_password | localhost |
| root | | auth_socket | localhost |
+------------------+------------------------------------------------------------------------+---------
以上就是修改用户密码加密方式的方法。