Reset MySQL root password

Reference: (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> 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.

Related Posts

20 most common passwords

I wouldn’t want this post to disappear, so just to make sure that...

Import MySQL tables from .myd

This is an easy procedure to import any MyISAM table that you would...


  • 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!

Comments are closed.