Home > Development, English, técnico, Tech Crunch, Techie > Reset MySQL root password

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> 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.
  1. June 2, 2011 at 1:57 am

    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!

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: