新裝的MySQL沒有密碼怎麼辦

新裝的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還不支持該種方式python

解決:mysql

在數據庫命令行中輸入:ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';

 

從新鏈接就OKsql

 

關注公衆號:

相關文章
相關標籤/搜索