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 you have located the correct executable, let’s go to the password question (in the case of Windows you don’t even need to, just do everything by the Services panel, the services.msc
).
There is a possibility that is to use a boot option for this:
--skip-grant-tables
The precaution to take is that this option makes Mysql accept as root any user that connects, so it should only be used so that you have access to DB and solve the password problem.
To use via command line, just stop the instance and run manually with the parameter --skip-grant-tables
, fix the DB by putting the desired password in the way you find most convenient, and after changing the password restart the service normally without the --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 right in after password exchange, restarting the service normally).
It is advisable to 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 makes the instance respond only to the local address, leaving the operation safer.
If you need to specify where my.ini
or equivalent file, since it is calling the server manually, has this option:
--defaults-file=/etc/my.ini
Alternative with startup script
Originally this was a user response Bruno Bermann, but for some reason was removed. I didn’t test it, but in theory it makes sense. It’s here as a reference for those who want to test.
In general lines, you can specify a startup file like this:
mysqld --init-file="C:\\Caminho\\init.txt"
and, in theory, on this path could have something like
UPDATE mysql.user SET Password=PASSWORD('SenhaNova') WHERE user='root';
FLUSH PRIVILEGES;
to change the desired password.
If the
nt
is the argument, a space after themysqld
if not he will try to find an executable with that name.– rray
Okay @rray, I tried to perform the commands, see: C: Program Files Mysql Mysql Server 5.6 bin>mysqld -nt 2016-07-06 17:20:20 0 [Warning] option 'new': Boolean value’t' wasn’t recognize d. Set to OFF. 2016-07-06 17:20:20 0 [Warning] TIMESTAMP with implicit DEFAULT value is depreca Ted. Please use --explicit_defaults_for_timestamp server option (see documentati on for more Details). 2016-07-06 17:20:20 0 [Note] mysqld (mysqld 5.6.25) Starting as process 5048 ...
– Rafael Assmann