Home > Database > Mysql Tutorial > Why Am I Getting 'ERROR 1045 (28000): Access Denied for User' When Connecting Remotely to MySQL?

Why Am I Getting 'ERROR 1045 (28000): Access Denied for User' When Connecting Remotely to MySQL?

DDD
Release: 2024-12-22 15:16:15
Original
892 people have browsed it

Why Am I Getting

How to Resolve "ERROR 1045 (28000): Access Denied for User" for Remote MySQL Connections

Despite having the MySQL port open and local access enabled, remote connections may fail with the error "ERROR 1045 (28000): Access denied for user." This indicates that additional steps are necessary to enable remote MySQL access.

  1. Add an IP-Specific User:

Start by modifying the mysql.user table to include an entry specifically for the remote IP address you're connecting from:

GRANT ALL PRIVILEGES ON *.* TO 'root'@'192.168.233.163' IDENTIFIED BY 'password';
FLUSH PRIVILEGES;
Copy after login

Replace '192.168.233.163' with the remote IP and 'password' with the root password.

  1. Grant Grant Option:

To grant remote users the ability to create databases and users, you need to also include the 'GRANT OPTION' when granting privileges:

GRANT ALL PRIVILEGES ON *.* TO 'remote_user'@'192.168.233.163' IDENTIFIED BY 'password' WITH GRANT OPTION;
FLUSH PRIVILEGES;
Copy after login
  1. Restart MySQL:

After making these changes, restart MySQL to ensure they take effect.

  1. Confirm Remote Access:

Once MySQL has been restarted, try connecting remotely again:

mysql --host=192.168.233.142 --user=remote_user --password=password
Copy after login

You should now be able to connect to MySQL remotely without encountering the access denied error.

The above is the detailed content of Why Am I Getting 'ERROR 1045 (28000): Access Denied for User' When Connecting Remotely to 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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template