1

I accidentally deleted all privileges for root and users. I would like to know how to restore them. I don't have access to USER privileges for any other user.

0

Restart mysqld_safe with this option added --skip-grant-tables

That will work only from localhost, and gives you a clean slate for creating a new root password.

0

Stop the mysqld service

service mysqld stop

Launch with skip grant option

mysqld_safe --skip-grant-tables &> /dev/null &

Login

mysql -u root

Recreate the user

CREATE USER 'root'@'localhost' IDENTIFIED BY 'somepasswordorsomething';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION;

Flush the privileges

FLUSH PRIVILEGES;

Kill mysqld

kill $( ps aux | grep mysqld_safe | awk '{print $2}' ) 

Restart the service, reenabling the grant table.

service mysqld start

This should have recreated the root user that you had previously.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.