Home >Database >Mysql Tutorial >How Can I Allow Remote MySQL Access from Any IP Address?

How Can I Allow Remote MySQL Access from Any IP Address?

Barbara Streisand
Barbara StreisandOriginal
2024-12-28 07:06:32408browse

How Can I Allow Remote MySQL Access from Any IP Address?

Allowing Remote Access to MySQL Database from Any IP Address

In order to grant remote access to a MySQL database from any IP address, you can utilize the wildcard character % in the GRANT statement. By replacing the 'yourremotehost' portion of the provided command with the wildcard, you are essentially allowing any remote host to access the database.

Here's the modified GRANT statement for this purpose:

GRANT ALL PRIVILEGES
ON database.*
TO 'user'@'%'
IDENTIFIED BY 'newpassword';

The "%" character serves as a wildcard, enabling connections from any remote host. You can further restrict access by using specific IP addresses or domains with wildcards, such as '%domain.example' or '3.123.123.123'.

For instance, to grant access to all hosts within a specific domain, use:

GRANT ALL PRIVILEGES
ON database.*
TO 'user'@'%.domain.example'
IDENTIFIED BY 'newpassword';

This provides a convenient solution for scenarios where you want to make your MySQL database publicly accessible, allowing connections from any remote host.

The above is the detailed content of How Can I Allow Remote MySQL Access from Any IP Address?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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