Recreate the root User
From Hashmysql
I've deleted the root user, and there's no other user with all privileges!
- Stop mysqld and restart it with the
--skip-grant-tables --user=root
options (Windows users omit the--user=root
portion). - Insert a record for the root user into the mysql.user table. The structure of the table changes with the version, so use the appropriate one:
- For 5.1 and 5.2:
-
INSERT INTO `user` VALUES ('localhost','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0);
- For 5.0:
-
INSERT INTO `user` VALUES ('localhost','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0);
- For 4.1:
-
INSERT INTO `user` VALUES ('localhost','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0);
- Stop mysqld and restart it as normal. You should now be able to login as root with a blank password.