Resetting Root Password on MYSQL

Posted: February 05, 2018 19:24 | By: Serge

There is a lot of old outdated information on Mysql... 

I struggled to reset Root password on a new client's server... here is the easy way to do this. Note that this will leave you vulnerable while in the skip-grant-table mode...

First, edit your my.cnf file, on UBUNTU you will find in at /etc/mysql/my.cnf

Add the following lines to it... 



Then simply restart your mysq service with 

sudo service mysql restart

You can then login to mysql as root without a password... with 

mysql -u root

You can then update the mysql.user table for root password... like 

UPDATE mysql.user SET authentication_string=PASSWORD('newpwd') WHERE User='root';
Or if you are running an older version of MySql

UPDATE mysql.user SET Password=PASSWORD('newpwd') WHERE User='root';

Don't forget to flush privileges...

flush privileges;

Then you shoud be good to go, simply remove the lines in the my.cnf file... and restart mysql again... 

You should also note that if you want to connect as root with a non root user, you will have to sudo into mysql or su root... 


Hi, my name is Serge Lachapelle, a nerdy entrepreneur from Montreal, Canada. I love tech, startups, business and freedom in general. I share my experiences here as I re-invent the way I work. Let's connect and create something cool...

Subscribe to new posts


Laravel 3

LIfe 1

Programming 4

Startup 1

Technology 1

VueJS 1

Recent Posts


Laravel the source of all the awsomeness...

Laracast well worth the money, great training...

VueJS simple and logical javascript framework...


This is my personal blog. I decided to share my journey as I re-invent the way I work. I figured that other older programmers and entrepreneurs would share this quest to return to understanding the mechanics in order to reboot our creativity. I would be delighted if you followed my ramblings on Twitter or connect on LinkedIn...

Social Links


I live in,
Montreal, Quebec