Remote Access Permissions for MySQL Server: Granting Root User Access
Remote access to a MySQL server allows users to connect and interact with the database from machines outside the localhost environment. By default, the root user is only authorized to access the server from the local machine.
To grant remote access permissions to the root user, follow these steps:
Connect to the MySQL server and execute the following query:
1 |
|
This will display the current access privileges granted to the root user.
If you want to grant access to specific hosts or subnets, use the following syntax:
1 |
|
Replace host_or_subnet with the hostname, IP address, or subnet mask (e.g., %.example.com or 192.168.1.%).
After granting the new permissions, execute the following query to apply them:
1 |
|
In cases where name resolution is unreliable, you can grant access by IP or subnet instead:
1 2 |
|
For further details, refer to the MySQL GRANT syntax documentation.
The above is the detailed content of How to Grant Remote Access to the MySQL Root User?. For more information, please follow other related articles on the PHP Chinese website!