Home >Database >Mysql Tutorial >How to Allow Remote Connections in MySQL?
Allowing Remote Connections in MySQL
Unlike SQL Server, MySQL requires manual configuration to allow remote database connections. To achieve this, you can utilize the GRANT command. Rather than granting permissions to individual IP addresses, you can grant access to all remote connections by using the '%' wildcard.
Command:
GRANT ALL ON *.* to user@'%' IDENTIFIED BY 'password';
This command grants all privileges to the user with the specified password, allowing them to connect from any host.
Additional Considerations:
However, it's important to note that additional steps may be required for the remote connection to work. Specifically, a user account from localhost must be created for the same user. This is because the anonymous account created by mysql_install_db may take precedence otherwise, preventing the remote connection from authenticating properly.
Therefore, for a user named 'user' to connect from any server, the following two accounts must be created:
GRANT ALL ON *.* to user@localhost IDENTIFIED BY 'password'; GRANT ALL ON *.* to user@'%' IDENTIFIED BY 'password';
By following these steps, you can effectively allow all remote connections in your MySQL database while maintaining proper security measures. Remember that this approach is only recommended for development databases within a controlled network environment.
The above is the detailed content of How to Allow Remote Connections in MySQL?. For more information, please follow other related articles on the PHP Chinese website!