Troubleshooting Remote MySQL Access for User@'%'
When attempting to establish a remote MySQL connection using the user@'%' wildcard, users may encounter difficulties if the user is not also created locally. The '%' wildcard permits connections from any host, but this permission is not enabled by default.
To grant remote access, several prerequisites must be met:
-
Bind MySQL to Machine IP: Edit the my.cnf configuration file (or my.ini on Windows) and set the bind-address parameter to the IP address of your machine. This allows MySQL to accept connections from remote hosts.
-
Create User with '%': Create a user with the '%' wildcard, granting them access to the database. This step complements the local user creation, ensuring that the user can connect from both local and remote hosts.
-
Grant Permissions: Assign appropriate permissions to the user created with the '%'. The GRANT ALL ON *.* command grants full permissions on all databases.
-
Flush Privileges: Run the FLUSH PRIVILEGES command to update the permission cache.
-
Open Port 3306: Depending on the operating system used, it may be necessary to open port 3306 on the firewall to allow incoming remote connections.
By following these steps, users can successfully establish remote MySQL connections using the user@'%' wildcard.
The above is the detailed content of Why Can't I Access My Remote MySQL Server Using user@'%'?. For more information, please follow other related articles on the PHP Chinese website!