出现 1251 错误代码
是因为 mysql8.0 的密码加密方式与之前 5.0 的不同
如果是字母式的密码 比如 root 可能会出现这种情况
1. 先通过命令行进入 MySQL https://www.2cto.com/database/MySQL/ 的 root 账户
- Enter password: ****
- Welcome to the MySQL monitor. Commands end with ; or \g.
- Your MySQL connection id is 10
- Server version: 8.0.17 MySQL Community Server - GPL
- Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
- Oracle is a registered trademark of Oracle Corporation and/or its
- affiliates. Other names may be trademarks of their respective
- owners.
- Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
2. 更改加密方式
- MySQL> ALTER USER 'root'@'localhost' IDENTIFIED BY 'password' PASSWORD EXPIRE NEVER;
- Query OK, 0 rows affected (0.08 sec)
3. 更改密码
- MySQL> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';
- Query OK, 0 rows affected (0.02 sec)
4. 刷新
- MySQL> FLUSH PRIVILEGES;
- Query OK, 0 rows affected (0.01 sec)
5. 完成
来源: http://www.bubuko.com/infodetail-3289541.html