Reset MySQL “root” Password from terminal

It’s very helpful in case I don’t remember MySQL root password at all neither any other account that have root privileges.

Here are all the steps:

Open terminal then stop MySQl server

Start MySQL server with option: skip-grant-tables

if the following error occur:

create directory /var/run/mysqld manually then change it’s ownership to mysql user

Connect to the MySQL server using root but with empty password

by running the above command I should now be able to get into MySQL command line interface (cli)

Reset root password

in this scenario I will reset root password into blank

Restart MySQL Server

notes: this article has been tested with Ubuntu Xenial and MySQL Server 5.7.22



enterprise architect. tech enthusiast. coffee addict.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store