Mysql – Can’t change root password: “The system cannot find the file specified.”

MySQLmysqladmin

I'm trying to change the root password in MySQL on my development machine (I've just installed MySQL, so it currently doesn't have a password), but it keeps failing with the following error message:

The system cannot find the file specified.

I'm using MySQL 5.1.70 (x86, 32-bit) on Windows 7 SP1 (64 bits). I've added MySQL's "bin" directory to my "Path" environment variable.

In the comments of the MySQL documentation, I read that I should have installed the service using the absolute path, so I stopped MySQL, and uninstalled it:

C:\Windows\system32>mysqld --remove
Service successfully removed.

Then I installed it again, using the absolute path this time:

C:\Windows\system32>C:\web\mysql-5.1.70\bin\mysqld.exe --install
Service successfully installed.

I started MySQL, and tried to change the password again:

C:\Windows\system32>mysqladmin -u root password Pe%8XiduwOqdZ<ZFE5!
The system cannot find the file specified.

I also tried with quotes:

C:\Windows\system32>mysqladmin -u root password 'Pe%8XiduwOqdZ<ZFE5!'
The system cannot find the file specified.

I also tried to change the current directory to MySQL's "bin" directory:

C:\Windows\system32>cd C:\web\mysql-5.1.70\bin

C:\web\mysql-5.1.70\bin>mysqladmin -u root password Pe%8XiduwOqdZ<ZFE5!
The system cannot find the file specified.

C:\web\mysql-5.1.70\bin>mysqladmin -u root password 'Pe%8XiduwOqdZ<ZFE5!'
The system cannot find the file specified.

What's wrong?

Best Answer

There are two techniques you can try:

TECHNIQUE #1

The comment from Michael - sqlbot already said it. Use double quotes

mysqladmin -u root password "Pe%8XiduwOqdZ<ZFE5!"

TECHNIQUE #2

root@localhost has no password. Try running this:

mysql -uroot -e"SET SQL_LOG_BIN = 0; SET PASSWORD = PASSWORD('mynewpassword');"

This should do it as well.

CAVEAT FOR MySQL 5.6 users : TECHNIQUE #2 will not work in Linux for MySQL 5.6. There is a separate file with the temp password for root@localhost ( ${HOME}/.mysql_secret ). You login with that password and change the password from there.

Give it a Try !!!