MySQL - Access Denied for User
Despite creating a new user with the necessary privileges, you may encounter the "Access denied" error when attempting to connect to the database. This issue arises due to an incorrect grant statement.
The error message indicates that the user 'servname_shb'@'localhost' does not have access to the database. To rectify this, use the following grant statement:
GRANT ALL ON *.* TO 'servname_shb'@'localhost';
This grants the specified user full access to all databases and tables on the local host. Alternatively, you can limit the access to only the required components by specifying specific databases or tables in the grant statement.
For example, to grant access to the 'servname_shbusers' database only:
GRANT ALL ON servname_shbusers TO 'servname_shb'@'localhost';
To further secure the database, it is recommended to limit the user's access to only the necessary privileges. Using the GRANT statement with specific privileges allows you to restrict the user's ability to perform certain actions, such as creating, altering, or deleting data.
Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.
Copyright© 2022 湘ICP备2022001581号-3