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
Release: 2024-12-28 07:06:32
Original
405 people have browsed it

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

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

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!

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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template