How to reset root MySQL password on Ubuntu 18.04 Bionic Beaver Linux -

The objective is to reset lost root MySQL password on Ubuntu 18.04 Bionic Beaver Linux. The simplest approach to reset MySQL database root password is to execute mysql_secure_installation program and when prompted entering your new root MySQL password:

$ sudo mysql_secure_installation

This is a companion discussion topic for the original entry at



Wendy Sukmajaya
it works for me…
but I wonder how to change password for ‘sysop’@‘localhost’


Muhammad Baiquni

It seems not work to me. I still has this error message:

mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 1698 (28000): Access denied for user 'root'@'localhost'

I have repeat your step more than twice and still I cannot login to MySQL


Marlin Forbes - > Muhammad Baiquni
With mysqld running, do this:

sudo mysql_secure_installation

It will ask you for a root password and some security questions. Done.


Lubos Rendek MOD -> Marlin Forbes
Hi Marlin,

Well this is a GURU solution :slight_smile: ! The article is now updated to include your suggestion. Thank you for your input.


James Gonzales
You have no idea how much I appreciate this article!! I have had hell trying to reset the root password until I stumbled upon this. I am thankful for people like you and your willingness and ability to share things like this. THANK YOU VERY MUCH!!!


Pablo Gadino

"SET PASSWORD..." fails: EROR 1524: plugin auth_socket is not loaded


Lubos Rendek Mod -> Pablo Gadino

This seems to be a result of a resent change in mysql mechanism. Article is now updated. thank you


Nice to see both solutions in the same place — but for whatever reason, on my system Lubos solution worked, while Marlin’s solution did not.


Excellent. I was allover the interverse trying to solve my problem of an unprotected Database.

Thanks a lot.


Thank you!! I happy its the first article that actually includes all the proper steps for Ubuntu 18, usually its a lots of researching to get through the full procedure!

A little more work to be able to comment though :stuck_out_tongue: