Reseting MySQL root password
Step One: Stop mysql service:
$sudo /etc/init.d/mysql stop Stopping MySQL database server: mysqld.
Step Two: Start to MySQL server w/o password:
$sudo mysqld_safe --skip-grant-tables & [1] 5988 Starting mysqld daemon with databases from /var/lib/mysql mysqld_safe[6025]: started
Step Three: Connect to mysql server using mysql client:
$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>
Step Four: Setup new MySQL root user password:
mysql> use mysql; mysql> update user set password=PASSWORD("NEW-ROOT-PASSWORD") where User='root'; mysql> flush privileges; mysql> quit
Obs: if your MySQL version is 5.6 or higher, use the column authentication_string instead password.
Step Five: Stop MySQL Server:
$sudo /etc/init.d/mysql stop Stopping MySQL database server: mysqld STOPPING server from pid file /var/run/mysqld/mysqld.pid mysqld_safe[6186]: ended [1]+ Done mysqld_safe --skip-grant-tables
Step Six: Start MySQL server and test it:
$sudo /etc/init.d/mysql start $mysql -u root -p
Sources:
- http://www.cyberciti.biz/tips/recover-mysql-root-password.html