Home >Database >Mysql Tutorial >Why Are My Non-Root MySQL Users Getting 'Access Denied' Errors?
MySQL: Troubleshooting Access Denied for Non-Root Users
The issue arises when non-root MySQL users encounter access denial errors, as demonstrated in the provided example. To resolve this problem, follow these steps:
Review Role Assignment:
Avoid assigning "all privileges on all databases" to non-root users, as this is a security risk. Consider limiting privileges to specific databases and individual operations.
Use On-Database Privileges:
Instead of granting broad privileges across all databases, use the "ON database.*" syntax to grant privileges for specific databases. For example:
Check User Privileges:
To view user privileges, log in as "root" and run the following query:
Verify User & Host:
Ensure that the user and host specified in the error message ("golden'@'localhost'") match the ones used in the privilege grant statements.
Restart MySQL:
After making changes, restart MySQL to ensure they take effect.
Additional Troubleshooting Tips:
The above is the detailed content of Why Are My Non-Root MySQL Users Getting 'Access Denied' Errors?. For more information, please follow other related articles on the PHP Chinese website!