Reset MySQL root password

Reference: http://www.cyberciti.biz/tips/recover-mysql-root-password.html (partly copied to avoid loosing source)

# /etc/init.d/mysql stop

Stopping MySQL database server: mysqld.
# mysqld_safe --skip-grant-tables &
[1] 5988
Starting mysqld daemon with databases from /var/lib/mysql
mysqld_safe[6025]: started
# mysql -u root
Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 1 to server version: 4.1.15-Debian_1-log

Type 'help;' or 'h' for help. Type 'c' to clear the buffer.
mysql>
mysql> use mysql;

mysql> update user set password=PASSWORD("NEW-ROOT-PASSWORD") where User='root';

mysql> flush privileges;

mysql> quit
# /etc/init.d/mysql stop

Personal note: use --skip-syslog if it fails.
http://www.cyberciti.biz/tips/recover-mysql-root-password.html
It's only fair to share...Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInShare on TumblrEmail this to someone

One Comment

  1. For extra safety, it`s best to –skip-networking also, as you`ll have a (hopefully short) period where remote users will be able to access databases/tables without the usual restrictions.

    Good blog!

Leave a Reply

Your email address will not be published. Required fields are marked *