新装的MySQL没有密码怎么办

新装的mysql没有密码怎么办

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
[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还不支持该种方式

解决:

1
在数据库命令行中输入:ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';

 

重新连接就OK

 

关注公众号:

posted @   QYGQH  阅读(416)  评论(0编辑  收藏  举报
编辑推荐:
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
阅读排行:
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 地球OL攻略 —— 某应届生求职总结
· 提示词工程——AI应用必不可少的技术
· Open-Sora 2.0 重磅开源!
· 周边上新:园子的第一款马克杯温暖上架
点击右上角即可分享
微信分享提示