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...
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...