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

How to Grant Remote MySQL Access from Any IP Address?

Patricia Arquette
Release: 2024-12-15 18:16:11
Original
624 people have browsed it

How to Grant Remote MySQL Access from Any IP Address?

Granting Remote Access to MySQL Database from any IP Address

In MySQL, granting remote access privileges allows external hosts to connect to and manipulate the database. By default, remote connections are restricted based on the host IP address. However, there are situations where you may want to allow access from any remote host, effectively making the database publicly accessible.

The standard GRANT command can be used to grant remote access, but it requires specifying a specific host IP address:

GRANT ALL PRIVILEGES
ON database.*
TO 'user'@'123.456.789.101'
IDENTIFIED BY 'newpassword';
Copy after login

To grant remote access from any IP address, the wildcard character '%', which matches any host, can be used instead of the IP address:

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

This will grant the specified user access to the database from any remote host. Note that using the wildcard character makes the database accessible to anyone with an internet connection, so it should be used with caution and appropriate security measures must be taken to protect the data.

Additionally, you can also use wildcards for specific parts of the host string. For example:

  • %.domain.example grants access from any host within the domain "example"
  • %.123.123.123 grants access from any host with an IP address that ends with "123.123.123"

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