新装的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还不支持该种方式
解决:
在数据库命令行中输入:ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
重新连接就OK