home / blog

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

Based on these instructions. http://dev.mysql.com/doc/refman/5.0/en/resetting-permissions.html.

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;

This entry was posted in geek and tagged , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published.