Deleted MySql root user accidently? Recreate root account

Deleted MySql root user accidently?

Follow the steps recreate the root user.

  1. If mysql service is already running, stop it.
  2. Open the command prompt and goto MYSQL_HOME/bin directory.
  3. Run following commands


> mysqld --skip-grant-tables

Then start mysql console

> mysql –u=root

Then run following commands

> GRANT CREATE, DROP ON *.* TO root@localhost IDENTIFIED BY 'newpass' WITH GRANT OPTION;

> GRANT ALL PRIVILEGES ON *.* TO root@localhost IDENTIFIED BY 'newpass' WITH GRANT OPTION;

Then restart the mysql service and you are done.

Advertisements