#[email protected] sudo /etc/init.d/mysqld stopSecondly create a sql script:
#[email protected] sudo vi /root/mysql.passwd-reset.sqlThen add the following code to the new sql file:
UPDATE mysql.user SET Password=PASSWORD('YOUR-NEW-MYSQL-PASSWORD') WHERE User='root'; FLUSH PRIVILEGES;Thirdly start mysql in safe mode and load the new sql file:
#[email protected] sudo mysqld_safe --init-file=/root/mysql.passwd-reset.sql &You will see something like this:
nohup: ignoring input and redirecting stderr to stdout Starting mysqld daemon with databases from /var/lib/mysql mysqld_safe[20970]: startedFinally restart the mysqld again:
#user@www /etc/init.d/mysqld stop #[email protected] /etc/init.d/mysqld startEnjoy.