docker 1045-Access denied for user 'root'@'localhost
时间: 2023-09-29 13:07:58 浏览: 46
引用:ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) 解决: 1.打开在创建mysql容器时挂载的conf目录下的mysqld.cnf(如下文件) 我创建docker的姿势 2.进入mysqlId.cnf文件中在...。 引用:这个报错是由于root密码不对(可能你记错了),重置root 密码就可,方法如下,亲试有效(Windows环境下)! 1 管理员身份进入cmd 。 引用:2.3 再次编辑my.ini文件,删除刚才输入的 skip-grant-tables 命令,保存,退出。进入刚才的cmd窗口,执行以下命令,成功: C:\windows\system32>net stop mysql //再次停止mysql服务 MySQL 服务正在停止. MySQL 服务已成功停止。 C:\windows\system32>net start mysql //再次开启mysql服务,使刚才修改的my.ini文件生效 MySQL 服务正在启动 . MySQL 服务已经启动成功。 C:\windows\system32>mysql -uroot -p //登录root账户,在下面输入密码123456,连接成功! Enter password: ****** Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 Server version: 5.6.21 MySQL Community Server (GPL) Copyright (c) 2000, 2014, 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> 。
这个报错是由于root密码不正确导致的。您可以尝试重置root密码来解决这个问题。以下是在Windows环境下重置root密码的步骤:
1. 以管理员身份打开cmd。
2. 输入以下命令停止MySQL服务:
C:\windows\system32> net stop mysql
3. 编辑MySQL配置文件my.ini,删除skip-grant-tables命令,并保存退出。
4. 再次在cmd窗口中输入以下命令启动MySQL服务:
C:\windows\system32> net start mysql
5. 登录root账户,并输入新的密码来连接MySQL:
C:\windows\system32> mysql -uroot -p
Enter password: ******(输入新密码)
这样就成功连接到MySQL了。