今天下了个 MySQL8.0,发现Navicat连接不上,总是报错1251;
原因是MySQL8.0版本的加密方式和MySQL5.0的不一样,连接会报错。
试了很多种方法,终于找到一种可以实现的:
更改加密方式
1.先通过命令行进入mysql的root账户:
?
1PS C:\Windows\system32> mysql -uroot -p
再输入root的密码:
Enter password: ******
Welcome tothe MySQL monitor. Commands endwith; or\g.
Your MySQL connectionid is18
Server version: 8.0.11 MySQL Community Server - GPL
Copyright (c) 2000, 2018, Oracle and/orits affiliates. Allrights reserved.
Oracle isa registered trademark ofOracle Corporation and/orits
affiliates. Other names may be trademarks oftheir respective
owners.
Type 'help;'or'\h'forhelp. Type '\c'toclear the currentinput statement.
mysql>
2.更改加密方式:
mysql> ALTERUSER'root'@'localhost'IDENTIFIED BY'password'PASSWORDEXPIRE NEVER;
Query OK, 0 rowsaffected (0.10 sec)
3.更改密码:该例子中 123为新密码
mysql> ALTERUSER'root'@'localhost'IDENTIFIED WITHmysql_native_password BY'123';
Query OK, 0 rowsaffected (0.35 sec)
4.刷新:
mysql> FLUSH PRIVILEGES;
Query OK, 0 rowsaffected (0.28 sec)
// 如果报错ERROR 1396 (HY000): Operation ALTER USER failed for 'root'@'%':
则是远程访问权限不正确,先选择数据库,查看一下再更改:
mysql> use mysql;
Databasechanged
mysql> selectuser,host fromuser;
+------------------+-----------+
| user| host |
+------------------+-----------+
| mysql.infoschema | localhost |
| mysql.session | localhost |
| mysql.sys | localhost |
| root | localhost |
+------------------+-----------+
5 rowsinset(0.00 sec)