MySQL Shell连接数据库报MySQL Error 1045 (28000)错误浅析

这里简单总结一下mysql shell访问数据库时报MySQL Error 1045 (28000): Access denied for user 'root'@'::1' (using password: YES)的原因以及如何解决这个问题

这里测试的环境为MySQL 8.0.35,我们先来看看报错案例:

$ mysqlsh -h localhost -P 7306 -u root -p<br>Please provide the password for 'root@localhost:7306': ***********<br>MySQL Shell 8.0.35<br><br>Copyright (c) 2016, 2023, Oracle and/or its affiliates.<br>Oracle is a registered trademark of Oracle Corporation and/or its affiliates.<br>Other names may be trademarks of their respective owners.<br><br>Type '\help' or '\?' for help; '\quit' to exit.<br>Creating a session to 'root@localhost:7306'<br>MySQL Error 1045 (28000): Access denied for user 'root'@'::1' (using password: YES)<br>