Like the fool I am, whilst messing about with user privileges in phpMyAdmin I managed to delete the root account. Suddenly I found myself with no access to any of my databases
It took a while to figure out how to re-create the root@localhost user, so here’s how I did it.
- Shut down mysql server
- Start the msql server up with skip-grant-tables option
- Log in to mysql
- Change to the mysql database
- Create the root user
- Re-start mysql server
For those that like a cut n paste approach, these are the commands:
service mysqld stopmysqld_safe --skip-grant-tables &mysqluse mysqlcreate user root@localhost;GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' with grant option;commit;FLUSH PRIVILEGES;exitservice mysqld restart
You can confirm that the root account has been created (or is indeed missing!) by listing entries on the user table:
use mysql;
select Host,User from user;
Good luck!
Kev.
Tags: mysql





Unable to use these steps. Getting an erro:
The MySQL server is running with the –skip-grant-tables option so it cannot execute this statement
I also got this error, but found that switching to the mysql schema first by typing ‘use mysql’ solved the problem.