How to recover MYSQL password with mysqld error

1

But this error occurs:

C:\Program Files\MySQL\MySQL Server 5.6\bin>
C:\Program Files\MySQL\MySQL Server 5.6\bin>mysqld-nt
'mysqld-nt' is not recognized as an internal or external command,
operable program or batch file.

Can anyone help me?

    
asked by anonymous 06.07.2016 / 20:00

1 answer

2

First of all, the error presented is simply because you either do not have an executable with this name on the machine, or you are not running with the correct path.

Once the correct executable is located, let's go to the password question (in case Windows does not need it, just do everything through the Services panel, services.msc ).

There is a possibility of using a boot option for this:

--skip-grant-tables

The care taken is that this option causes MySQL to accept as root any user who connects, so it should only be used for you to have access to the DB and resolve the password problem.

To use the command line, simply stop the instance and run it manually with the --skip-grant-tables parameter, store the DB by putting the desired password in the way it seems most convenient, and after changing the password > restart the service normally without --skip-grant-tables )

In Windows, you can run services.msc and put the parameter in the initialization options of the respective instance and restart the service (and remove soon after the change of password, restarting the service normally).

You should block third-party access to the machine during maintenance if you choose this solution.


Extra Considerations:

If you are going to make the change locally, using this parameter is of great value:

 --bind-address=127.0.0.1

This causes the instance to respond only to the local address, making the operation safer.


If you need to specify where the my.ini or equivalent file is, since you are calling the server manually, you have this option:

--defaults-file=/etc/my.ini


Alternative with initialization script

Originally this was a user response Bruno Bermann , but for some reason has been removed . I did not test, but in theory it makes some sense. It is here as a reference for anyone wanting to test.

In general terms, you can specify a boot file like this:

mysqld --init-file="C:\Caminho\init.txt"

And, in theory, this path could have something like

UPDATE mysql.user SET Password=PASSWORD('SenhaNova') WHERE user='root';
FLUSH PRIVILEGES;

to change the password you want.

    
06.07.2016 / 23:42