Home > Database > Mysql Tutorial > How Can I Recover Full Privileges for My MySQL Root User?

How Can I Recover Full Privileges for My MySQL Root User?

Barbara Streisand
Release: 2024-12-09 09:59:10
Original
514 people have browsed it

How Can I Recover Full Privileges for My MySQL Root User?

Regaining Full Privileges for MySQL Root User

When handling MySQL privileges, accidental alterations can lead to restricted access, hindering essential operations. If you've inadvertently stripped some privileges from the MySQL root user, restoring its full capabilities becomes crucial.

Solution

To reinstate the root user with all its privileges, follow these steps:

  1. Stop and Restart MySQL with --skip-grant-tables:
sudo service mysql stop
sudo service mysql start --skip-grant-tables
Copy after login
  1. Connect to MySQL without Password:
mysql
Copy after login
  1. Update User Privileges:
UPDATE mysql.user SET Grant_priv='Y', Super_priv='Y' WHERE User='root';
FLUSH PRIVILEGES;
Copy after login
  1. Grant Full Privileges:

Restart MySQL normally:

sudo service mysql restart
Copy after login

Then, execute this command again to grant unrestricted access to the root user:

GRANT ALL ON *.* TO 'root'@'localhost';
Copy after login

After these steps, the root user will regain all its privileges, allowing you to perform necessary alterations and manage MySQL effectively.

The above is the detailed content of How Can I Recover Full Privileges for My MySQL Root User?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template