Search This Blog

mysql: reset root password

  1. Stop mysql service:
    sudo service mysql stop
  2. Start mysqld with following arguments: --skip-grant-tables and --skip-networking:
    sudo mysqld --skip-grant-tables --skip-networking &
  3. Run following command to upgrade the database:
    sudo mysql_upgrade
  4. Connect to mysql server:
    mysql
  5. Run following SQL clauses to change root password:
    UPDATE mysql.user SET Password=PASSWORD('MyNewPass') WHERE User='root';
    FLUSH PRIVILEGES;
    
  6. Stop the msyql process:
    sudo killall -9 mysqld
  7. Start mysql service:
    sudo service mysql stop

See also

No comments:

Post a Comment