How to change the mysql root password

One option is to save UPDATE mysql.user SET Password=PASSWORD('newpass') WHERE User='root'; into a file and then manually start mysqld with --init-file=FILENAME. Once the server starts, it should reset your password, and then you should be able to log in. After this, you should shut down the server and start it normally.


A little late to the game, but I had the same issue on a raspberry pi install and found out that it needs elevation. Adding a sudo to the front of the password change allowed it to work.

sudo mysqladmin -u root password 'newpass'

followed by an elevated sql access

sudo mysql -u root -p  

If either are not run as sudo, it will fail.


The root user password is an empty string by default.

And (using password: NO) says that there is no password.

Do you try to login from another system? I imagine you can only login as root user locally.


I removed the MySQL installation and deleted the data files, and then reinstalled it.

Then I was able to set the root password. Once you set the root password to something. mysqladmin won't let you reset it if you don't know it.

To reset it, you've got to have ownership over how mysqld is executed, and feed it an init file to change the root password: https://dev.mysql.com/doc/refman/5.0/en/resetting-permissions.html