新装的mysql没有密码怎么办

[root@localhost log]# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 21
Server version: 8.0.15 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.

mysql> set password='123456';
Query OK, 0 rows affected (0.00 sec)
//或者
mysql> ALTER user 'root'@'localhost' IDENTIFIED BY '123456';

2.新版mysql(8.0+)连接数据库出现2059

原因:MySQL的8.0.*版本使用的是caching_sha2_password验证方式,而Navicat Premium 12还不支持该种方式

解决:

SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。
在数据库命令行中输入:ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';

 新装的MySQL没有密码怎么办 随笔 第1张

重新连接就OK

 

关注公众号:

新装的MySQL没有密码怎么办 随笔 第2张

扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄