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';
相關文章
相關標籤/搜索