MySQL 重新安装,但 root 密码仍然存在,我忘记了
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6067694/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
MySQL reinstalled, but root password still there and I forgot it
提问by Tim
I forgot my root password in MySQL 5.1 on Windows 7 I uninstalled and deleted the MySQL directory in Program Files
我在 Windows 7 上的 MySQL 5.1 中忘记了我的 root 密码我卸载并删除了 Program Files 中的 MySQL 目录
Then I installed 5.5, but get error 1045, saying: Access denied for user: 'root@localhost'
然后我安装了 5.5,但得到错误 1045,说: Access denied for user: 'root@localhost'
I thought that uninstalling MySQL, and reinstalling would allow me to create a new root password, but apparently not. Please help!
我认为卸载 MySQL 并重新安装可以让我创建一个新的 root 密码,但显然不是。请帮忙!
回答by chelmertz
There's a guide on mysql.com called Resetting the Root Password: Windows Systems.
mysql.com 上有一个指南,名为“重置根密码:Windows 系统”。
回答by Himanshu Aggarwal
Actually even after uninstalling the MySQL the data still remains in the directory which is not deleted by itself. So if you want to reinstall it from scratch then follow these simple steps:
实际上,即使卸载了 MySQL,数据仍然保留在不会自行删除的目录中。因此,如果您想从头开始重新安装它,请按照以下简单步骤操作:
Using Windows 7/8, here's what you need to do:
使用 Windows 7/8,您需要执行以下操作:
- Uninstall MySQL using the uninstaller
- Delete
C:\Program Files\MySQL - Delete
C:\Program Files (x86)\MySQL - Delete
C:\ProgramData\MySQL - Delete from any Users' AppData folders. Example:
C:\Users\rdoverby\AppData\Roaming\MySQL - Reinstall MySQL.
- 使用卸载程序卸载 MySQL
- 删除
C:\Program Files\MySQL - 删除
C:\Program Files (x86)\MySQL - 删除
C:\ProgramData\MySQL - 从任何用户的 AppData 文件夹中删除。例子:
C:\Users\rdoverby\AppData\Roaming\MySQL - 重新安装 MySQL。
And then it will hopefully work fine!
然后它有望正常工作!
回答by Lmwangi
It's easy to use the init-file option to mysqld
很容易使用 mysqld 的 init-file 选项
Add either
添加任一
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY 'blah' WITH GRANT OPTION;
Or preferably
或者最好
SET PASSWORD FOR root@localhost = PASSWORD('blah');
to a file say /reset.mysqld
到文件说 /reset.mysqld
Edit your /etc/my.cnfto point to this file
编辑您的/etc/my.cnf以指向此文件
[mysqld]
....
init-file=/reset.mysqld
...
Restart mysqld, remove /reset.mysqld and revert your my.cnf to what it was before.
重新启动 mysqld,删除 /reset.mysqld 并将您的 my.cnf 恢复到之前的状态。
回答by sajdev
- First uninstall MySQL Server
- Delete MySQL Server Application Data folder at
C:\Documents and Settings\All Users\Application Data\MySQL\MySQL Server 5.6(Windows XP). - Re-install MySQL Server via the MySQL installer.
- 首先卸载 MySQL 服务器
- 删除
C:\Documents and Settings\All Users\Application Data\MySQL\MySQL Server 5.6(Windows XP) 中的MySQL Server Application Data 文件夹。 - 通过 MySQL 安装程序重新安装 MySQL 服务器。
回答by diyoda_
The following worked for me just fine,
以下对我来说很好,
Now you can do this using the MYSQL installer.I downloaded the 250MB file. There you can remove all the tools (In cases they can be out dated) as well as all the MYSQL files (NOTE: These are asked to remove after uninstalling the existing tools) that causes these kind of problems. Then again you can install them using the same SQL installer.
现在您可以使用MYSQL 安装程序执行此操作。我下载了 250MB 的文件。在那里您可以删除所有导致此类问题的工具(以防它们过时)以及所有 MYSQL 文件(注意:卸载现有工具后要求删除这些文件)。然后您可以再次使用相同的 SQL 安装程序安装它们。
Problem solved.
问题解决了。

