Home > Database > Mysql Tutorial > body text

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

Patricia Arquette
Release: 2024-11-01 11:53:30
Original
472 people have browsed it

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

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!

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!