1. 修改用户密码
ALTER USER ‘native‘@‘localhost‘ IDENTIFIED WITH mysql_native_password BY ‘new_password‘;
2. 修改 MySQL 认证方式
可以按照下面红色字体操作更改 Mysql 默认认证方式
When running a PHP version before 7.1.16, or PHP 7.2 before 7.2.4, set MySQL 8 Server's default password plugin to mysql_native_password or else you will see errors similar to The server requested authentication method unknown to the client [caching_sha2_password] even when caching_sha2_password is not used.
This is because MySQL 8 defaults to caching_sha2_password, a plugin that is not recognized by the older PHP (mysqlnd) releases. Instead, change it by setting default_authentication_plugin=mysql_native_password
in my.cnf. The caching_sha2_password plugin will be supported in a future PHP release. In the meantime, the mysql_xdevapi extension does support it.
在配置中指定认证方式 /etc/my.cnf
default-authentication-plugin=mysql_native_password
3. 初始密码
安装后会在日志文件(/var/log/mysqld.log)中生成一个默认密码 A temporary password is generated for root@localhost:
可以使用以下命令修改初始密码:
set password='your password';
4 查看字符集
SHOW VARIABLES LIKE 'character%'