ERROR 1045 (28000)Access denied for user root localhost using passwordNO

本文提供了一种在Windows环境下重置MySQL root用户密码的方法,并针对Win7系统中出现的未知列'password'的问题给出了正确的解决方案。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

参考网址:
具体办法:
Follow the steps given below:
  1. Stop your MySQL server completely. This can be done by accessing the Services window inside Windows XP and Windows Server 2003, where you can stop the MySQL service.
  2. Open your MS-DOS command prompt using "cmd" inside the Run window. Inside it navigate to your MySQL bin folder, such as C:\MySQL\bin using the cd command.
  3. Execute the following command in the command prompt: mysqld.exe -u root --skip-grant-tables
  4. Leave the current MS-DOS command prompt as it is, and open a new MS-DOS command prompt window.
  5. Navigate to your MySQL bin folder, such as C:\MySQL\bin using the cd command.
  6. Enter mysql and press enter.
  7. You should now have the MySQL command prompt working. Type use mysql; so that we switch to the "mysql" database.
  8. Execute the following command to update the password:
UPDATE user SET Password = PASSWORD('NEW_PASSWORD') WHERE User = 'root';
However, you can now run any SQL command that you wish.
After you are finished close the first command prompt and type  exit;  in the second command prompt windows to disconnect successfully. You can now start the MySQL service.

不过按照上面这样解决在我的WIN7电脑上执行 UPDATE user SET Password = PASSWORD('NEW_PASSWORD') WHERE User = 'root'; 命令时出现了另一个问题:
ERROR 1054 (42S22): Unknown column 'password' in 'field list'
参考网址:
晚上被这个问题折腾了好久,最后发现window下这个版本的mysql密码列是authentication_string,所以正确的写法是:
mysql>update mysql.user set authentication_string=password('123456') where user='root' and Host ='localhost';
问题解决
首次安装出现ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) 错误通常表示在试图使用root用户连接MySQL数据库时出现了拒绝访问的错误。这个问题可能有多种原因导致,下面我将为你提供几种可能的解决方法: 1. 确认密码:首先,请确保你使用的是正确的密码。确保在连接MySQL时使用了正确的密码。如果你不确定密码是否正确,可以尝试重置密码。 2. 检查用户名和主机:请确保使用的是正确的用户名和主机名。在某些情况下,MySQL可能会拒绝使用root用户连接本地主机。你可以尝试使用其他帐户连接数据库,或者在MySQL中创建一个新用户并授予相应的权限。 3. 检查访问权限:确保你具有访问数据库的必要权限。有时,新安装的MySQL可能会限制某些用户的访问权限。你可以使用root用户或具有适当权限的用户登录MySQL,并检查用户的权限。 4. 检查防火墙设置:如果你的操作系统上启用了防火墙,确保允许MySQL服务器的入站连接。你可以检查操作系统的防火墙配置,确保MySQL的端口(默认为3306)是开放的。 5. 检查MySQL配置文件:有时,MySQL的配置文件中的一些设置可能会导致访问被拒绝。请检查MySQL的配置文件(通常是my.cnf或mysqld.cnf),查看是否有任何不正确的配置或限制。 请根据你的具体情况尝试上述解决方法,希望能帮助到你解决问题。如果问题仍然存在,请提供更多详细信息,以便我们能够更准确地帮助你解决问题。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值