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.
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;
Replace '192.168.233.163' with the remote IP and 'password' with the root password.
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;
After making these changes, restart MySQL to ensure they take effect.
Once MySQL has been restarted, try connecting remotely again:
mysql --host=192.168.233.142 --user=remote_user --password=password
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!