I am trying to reset the root password for mySQL Workbench since I forgot it. I was reviewing some online tutorials of how to do this, and they all speak of a "bin" folder. I went to the program folder, and didn't see a bin folder. How do I do this?
-
This is on Winboze, right? Check in your "C:\mysql" for a "bin" folder– hovanessyanNov 22, 2011 at 18:52
-
7@hovanessyan "Winboze" ? seriously?– NasreddineNov 22, 2011 at 21:32
-
@droidus Did you find the solution? I have the same problem and I don't have mysql server installed.– PanizJan 27, 2015 at 8:02
3 Answers
Reset MySQL Root Password from PowerShell
1. Stop the MySQL service and process.
spsv mysql*
kill -f -Pro mysqld -ErrorA Ignore
2. Create a temporary init file
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.
$defaultsFile = (gci -r -Path "C:\ProgramData\MySQL" -include my.ini).FullName
4. Change dir to MySQL bin.
cd "C:\Program Files\MySQL\MySQL Server*\bin"
5. Run mysqld with the password reset.
& .\mysqld.exe --defaults-file="$defaultsFile" --init-file="C:\\temp.txt"
6. Kill and Restart MySQLD (in a new PowerShell prompt).
ps mysqld | kill -f
sasv "MySql*"
7. Return to the initial prompt and test
& .\mysql -u root -p4321
\q
Notes
- We cannot do anything until we stop MySql completely.
- Create this in
C:\
, then add reset password commands;ri
removes any existing temp.txt file. - You can retrieve this path through the Service Control Manager or use
(gwmi win32_service | ?{$_.Name -like 'mysql*'} | select -First 1).PathName
. - The
*
in the path means that we don't have to know our version number. - The
&
makes PowerShell run theexe
like the command line does. Once you run this, PowerShell will appear to hang - that's because it's running themysqld
process. - We need to kill in another process, because the existing console is busy.
- Return to the initial console, because it's already at
bin
. After the test, you should seemysql>
. Use\q
to quit.
See Also
http://dev.mysql.com/doc/refman/5.0/en/resetting-permissions.html
Reset MySQL root password official documentation has cases for Windows and Unix systems, and a "generic" instruction at the end of the document. Hope that helps.
-
what is winboze? mysql workbench 5.2 ce is located in program files (x86). here is an image of its location, and everythin inside of that folder. mediafire.com/imageview.php?quickkey=5zv5q2l9ikxc8j4– droidusNov 22, 2011 at 19:00
-
yeah, but you use MySQL Workbench to connect to a MySQL server - you need the mysql server binaries. What do you have up-one-folder from what you show in your screenshot? Nov 22, 2011 at 19:19
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 . I used mysqld.exe, because mysqld-nt.exe doesn't exist anymore in newer versions of 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
Note: make sure you run the CMD.exe as Administrator. For the most part that fixed it for me.