Forgot root password? Reset it (MySQL)

If you need to get into MySQL but don’t have a password all you need is linux root or sudo.

Here are the steps.

  1. sudo vi /etc/my.cnf   or sudo vi /etc/mysql/my.cnf
  2. add this:  skip_grant_tables under [mysqld]
  3. sudo /etc/init.d/mysqld restart
  4. mysql -uroot     (NO PASSWORD)
  5. UPDATE mysql.user SET Password=PASSWORD('MyNewPass') WHERE User='root'; FLUSH PRIVILEGES; exit;
  6. sudo vi /etc/my.cnf   or sudo vi /etc/mysql/my.cnf
  7. remove this: skip_grant_tables under [mysqld]
  8. sudo /etc/init.d/mysqld restart
Thats it.
Posted in Linux, MySQL, SQL

Leave a Reply