I am using MySQL. My root user doesn't have all privileges. How can I get all privileges back to the root user? How to do it step by step?
This worked for me on Ubuntu:
Stop MySQL server:
/etc/init.d/mysql stop
Start MySQL from the commandline:
/usr/sbin/mysqld
In another terminal enter mysql and issue:
grant all privileges on *.* to 'root'@'%' with grant option;
You may also want to add
grant all privileges on *.* to 'root'@'localhost' with grant option;
and optionally use a password as well.
flush privileges;
and then exit your MySQL prompt and then kill the mysqld server running in the foreground. Restart with
/etc/init.d/mysql start
If you facing grant permission access denied problem, you can try mysql_upgrade to fix the problem:
/usr/bin/mysql_upgrade -u root -p
Login as root:
mysql -u root -p
Run this commands:
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost';
mysql> FLUSH PRIVILEGES;
Log in as root, then run the following MySQL commands:
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost';
FLUSH PRIVILEGES;
来源:https://stackoverflow.com/questions/1708826/how-to-get-all-privileges-back-to-the-root-user-in-mysql