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

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

Linda Hamilton
Linda HamiltonOriginal
2024-12-20 16:18:09721browse

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

Granting Remote Access to MySQL Database from Any IP Address

When granting remote access to a MySQL database, the standard command typically specifies a specific IP address. However, if you wish to allow access from any remote host, a slight modification is required.

The revised command now grants privileges to a user with the wildcard '%' instead of a specific IP address:

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

By utilizing '%', the database is effectively made public, allowing access from any remote host. This character serves as a wildcard, enabling you to specify broader IP ranges or patterns, such as:

  • %.example.com: Allows access from any host within the "example.com" domain
  • %.123.123.123: Grants access from any host with the specified IP address prefix
  • %.: Provides unrestricted access from all IP addresses

The above is the detailed content of How Can I Grant 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