Home > Database > Mysql Tutorial > How to Allow Remote Connections in MySQL?

How to Allow Remote Connections in MySQL?

DDD
Release: 2024-11-19 03:19:02
Original
314 people have browsed it

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';
Copy after login

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';
Copy after login

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!

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