Home > Database > Mysql Tutorial > Why Am I Getting \'Access Denied\' When Creating a New User in MySQL?

Why Am I Getting \'Access Denied\' When Creating a New User in MySQL?

Mary-Kate Olsen
Release: 2024-10-31 06:15:30
Original
1013 people have browsed it

Why Am I Getting

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';
Copy after login

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!

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