mysql-8.0 新特性
- 認證方法更新爲了: caching_sha2_password
- 字符集改成了默認: utf8mb4
mysqli_connect: authentication method unknown to the client [caching_sha2_password]
解決辦法:
將認證方式和字符集改爲之前的方式
- 編輯mysql配置文件
vim /etc/my.cnf
[mysqld]
default_authentication_plugin=mysql_native_password
character_set_server =utf8
- 重啓mysql 服務
service mysqld restart
- 創建數據庫
create database dbname charset=utf8 collate=utf8_general_ci;
或更新數據庫
alter database dbname charset=utf8 collate=utf8_general_ci;
- 創建用戶,賦予權限
create user 'root'@'%' identified with mysql_native_password by '123456';
grant all on dbname.* to 'root'@'%';
flush privileges;