MySQL root password reset on debian/ubuntu – cut and paste

Based on these instructions.

Just cut and paste the following into a terminal to reset MySQL root password to ‘newpass123’

# stop existing service
sudo service mysql stop;
# start without access control
sudo mysqld --skip-grant-tables &
# wait until started
sleep 5;
# reset password
echo "UPDATE mysql.user SET password=PASSWORD('newpass123') WHERE user='root';FLUSH PRIVILEGES;" | mysql -h localhost;
# stop insecure instance
sudo killall -9 mysqld;
# start proper service
sudo service mysql start;

Leave a comment

Your email address will not be published.