简体   繁体   English

重置mysql workbench root密码

[英]resetting mysql workbench root password

I am trying to reset the root password for mySQL Workbench since I forgot it. 我正在尝试重置mySQL Workbench的root密码,因为我忘了它。 I was reviewing some online tutorials of how to do this, and they all speak of a "bin" folder. 我正在审查一些如何执行此操作的在线教程,他们都谈到了“bin”文件夹。 I went to the program folder, and didn't see a bin folder. 我去了程序文件夹,没有看到bin文件夹。 How do I do this? 我该怎么做呢?

Reset MySQL root password official documentation has cases for Windows and Unix systems, and a "generic" instruction at the end of the document. 重置MySQL root密码官方文档包含Windows和Unix系统的案例,以及文档末尾的“通用”指令。 Hope that helps. 希望有所帮助。

Reset MySQL Root Password from PowerShell 从PowerShell重置MySQL Root密码

1. Stop the MySQL service and process. 1.停止MySQL服务和进程。

spsv mysql*
kill -f -Pro mysqld -ErrorA Ignore

2. Create a temporary init file 2.创建临时init文件

ri C:\temp.txt
ni -t f C:\temp.txt 
ac C:\temp.txt "UPDATE mysql.user SET Password=PASSWORD('4321') WHERE User='root';"
ac C:\temp.txt "FLUSH PRIVILEGES;"

3. Get the location of the MySQL defaults-file. 3.获取MySQL默认文件的位置。

$defaultsFile = (gci -r -Path "C:\ProgramData\MySQL" -include my.ini).FullName

4. Change dir to MySQL bin. 4.将dir更改为MySQL bin。

cd "C:\Program Files\MySQL\MySQL Server*\bin"

5. Run mysqld with the password reset. 5.运行mysqld并重置密码。

& .\mysqld.exe --defaults-file="$defaultsFile" --init-file="C:\\temp.txt"

6. Kill and Restart MySQLD (in a new PowerShell prompt). 6.杀死并重新启动MySQLD(在新的PowerShell提示符下)。

ps mysqld | kill -f
sasv "MySql*"

7. Return to the initial prompt and test 7.返回初始提示并进行测试

& .\mysql -u root -p4321
\q

Notes 笔记

  1. We cannot do anything until we stop MySql completely. 在完全停止MySql之前,我们无法做任何事情。
  2. Create this in C:\\ , then add reset password commands; C:\\创建,然后添加重置密码命令; ri removes any existing temp.txt file. ri删除任何现有的temp.txt文件。
  3. You can retrieve this path through the Service Control Manager or use (gwmi win32_service | ?{$_.Name -like 'mysql*'} | select -First 1).PathName . 您可以通过服务控制管理器检索此路径或使用(gwmi win32_service | ?{$_.Name -like 'mysql*'} | select -First 1).PathName
  4. The * in the path means that we don't have to know our version number. 路径中的*表示我们不必知道我们的版本号。
  5. The & makes PowerShell run the exe like the command line does. &使PowerShell像命令行一样运行exe Once you run this, PowerShell will appear to hang - that's because it's running the mysqld process. 一旦你运行它,PowerShell似乎会挂起 - 这是因为它正在运行mysqld进程。
  6. We need to kill in another process, because the existing console is busy. 我们需要在另一个进程中终止,因为现有的控制台很忙。
  7. Return to the initial console, because it's already at bin . 返回初始控制台,因为它已经在bin After the test, you should see mysql> . 测试后,你应该看到mysql> Use \\q to quit. 使用\\q退出。

See Also 也可以看看

http://dev.mysql.com/doc/refman/5.0/en/resetting-permissions.html http://dev.mysql.com/doc/refman/5.0/en/resetting-permissions.html

Hey if you are on Windows 7 like me you will find the MySQL executables here: C:\\Program Files\\MySQL\\MySQL Server 5.5\\bin . 嘿,如果你像我一样在Windows 7上,你会在这里找到MySQL可执行文件:C:\\ Program Files \\ MySQL \\ MySQL Server 5.5 \\ bin。 I used mysqld.exe, because mysqld-nt.exe doesn't exist anymore in newer versions of MySQL. 我使用了mysqld.exe,因为mysqld-nt.exe在较新版本的MySQL中不再存在。

After following the instructions in the documentation you should have a command similar to this: C:\\Program Files\\MySQL\\MySQL Server 5.5\\bin>mysqld.exe --defaults-file="C:\\Program Files\\MySQL\\MySQL Server 5.5\\my-medium.ini" --init-file=C:\\mysql-initRootPass.txt 按照文档中的说明操作后,您应该有一个与此类似的命令:C:\\ Program Files \\ MySQL \\ MySQL Server 5.5 \\ bin> mysqld.exe --defaults-file =“C:\\ Program Files \\ MySQL \\ MySQL Server 5.5 \\ my-medium.ini“ - init-file = C:\\ mysql-initRootPass.txt

Note: make sure you run the CMD.exe as Administrator. 注意:确保以管理员身份运行CMD.exe。 For the most part that fixed it for me. 在大多数情况下为我修复它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM