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.
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.
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.