Follow the steps below to reset your MySQL password on CentOS.

  1. End the MySQLd demon service

    sudo /etc/init.d/mysqld stop

    killall -KILL mysql mysqld_safe mysqld

  2. Start MySQLd without passwords

    sudo mysqld_safe –skip-grant-tables &

  3. Run MySQL

    mysql -u root

  4. Flush the privileges

    FLUSH PRIVILEGES;

  5. Change the password

    use mysql;

    SET PASSWORD FOR root@’localhost’ = PASSWORD(‘password’);
    UPDATE user SET Password=PASSWORD(‘newpwd’) WHERE User=’root’;

  6. Flush the privileges once again

    FLUSH PRIVILEGES;

Advertisements