MySQL Access Denied for User
When attempting to create a new user in MySQL and grant them all privileges, users may encounter an "Access denied" error when trying to connect to the database. Despite creating the user and granting them permissions, the error persists.
To resolve this issue, the user must ensure that the GRANT statement specifies the hostname along with the username to which the privileges are being granted. The following modified GRANT statement should be used:
GRANT ALL ON *.* TO 'servname_shb'@'localhost';
This ensures that the user 'servname_shb' has access to all databases on the 'localhost' server. As suggested by @grantk in the comments, it is advisable to refine the access scope to only the necessary resources to enhance security.
The above is the detailed content of Why Am I Getting \"Access Denied\" When Creating a New User in MySQL?. For more information, please follow other related articles on the PHP Chinese website!