Home > Database > Mysql Tutorial > Why Am I Getting 'Access denied for user 'root'@'localhost'' When Granting Privileges?

Why Am I Getting 'Access denied for user 'root'@'localhost'' When Granting Privileges?

Mary-Kate Olsen
Release: 2024-12-10 07:34:13
Original
992 people have browsed it

Why Am I Getting

Unable to Grant Privileges as 'root'

When attempting to grant privileges as the root user with all necessary permissions, you may encounter the error "Access denied for user 'root'@'localhost.'" This issue arises when you try to grant privileges on the off-limits mysql.users table.

Solution:

To resolve this problem, grant privileges on a specific database instead of all tables. Use the following syntax:

GRANT ALL PRIVILEGES ON `%`.* TO '[user]'@'[hostname]' IDENTIFIED BY '[password]' WITH GRANT OPTION;
Copy after login

Here, % represents any database, and you can specify the database name in place of the asterisk (*). This approach excludes the mysql.users table from the privileges, allowing you to grant privileges to other users.

The above is the detailed content of Why Am I Getting 'Access denied for user 'root'@'localhost'' When Granting Privileges?. 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