mysql 迁移至 8.0 时的注意事项

密码模式

PDO::__construct(): The server requested authentication method unknown to the client [caching_sha2_password]

mysql8 以后,默认的密码模式改成 caching_sha2_password,新的模式须要新的驱动,至少如今 pdo / navicat 还没给出,因此咱们仍是得切换成老的 mysql_native_password 模式。mysql

`mysql_native_password`:7.0 如下
`caching_sha2_password`:8.0 以上

一、my.cnf 配置默认的密码模式sql

[mysqld]
default_authentication_plugin=mysql_native_password

二、更新帐号的密码模式ide

# 建立新的帐号
create user 'root'@'%' identified with mysql_native_password by '123456';

# 已存在的帐号
alter user 'root'@'%' identified with mysql_native_password by '123456';

三、若是你须要受权ui

# 受权也不能兼并建立帐号了,只能受权
grant all privileges on *.* to 'root'@'%' with grant option;
flush privileges;

密码复杂度策略

ERROR 1819 (HY000): Your password does not satisfy the current policy requirements


密码复杂度验证策略致使的,关闭后设定便可编码

set global validate_password.policy=0;
set global validate_password.length=6;

默认编码

PDO::__construct(): Server sent charset (255) unknown to the client. Please, report to the developers


设定 mysql 服务的默认编码code

# Default Homebrew MySQL server config
[client]
default_character_set=utf8mb4

[mysql]
default_character_set=utf8mb4

[mysqld]
default_authentication_plugin=mysql_native_password
character_set_server=utf8mb4
collation_server=utf8mb4_general_ci

远程访问

一、my.conf 注释掉本地监听server

[mysqld]
#bind_address=127.0.0.1

二、更新帐号的 hostci

update mysql.user set host='%' where user='root';
相关文章
相关标签/搜索