Home  >  Article  >  Database  >  MySQL Access Denied: Why Can\'t My User Connect from localhost?

MySQL Access Denied: Why Can\'t My User Connect from localhost?

Patricia Arquette
Patricia ArquetteOriginal
2024-11-01 11:53:30473browse

MySQL Access Denied: Why Can't My User Connect from localhost?

Resolving "Access denied for user" Error in MySQL

When attempting to connect to a MySQL database, the "Access denied for user" error may arise despite seemingly correct user creation and privilege granting.

To resolve this issue, it is crucial to ensure that the grant statement includes the hostname after the user name, as follows:

GRANT ALL ON *.* TO 'servname_shb'@'localhost';

This specifies that the user "servname_shb" is granted access to all databases and tables from the "localhost" host.

Additionally, refining the access scope to only the necessary privileges is recommended for enhanced security.

The above is the detailed content of MySQL Access Denied: Why Can\'t My User Connect from localhost?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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