Home >Database >Mysql Tutorial >How Can I Grant Remote Access to My MySQL Server?

How Can I Grant Remote Access to My MySQL Server?

Linda Hamilton
Linda HamiltonOriginal
2025-01-04 00:47:40325browse

How Can I Grant Remote Access to My MySQL Server?

Granting Remote Access Permissions to MySQL Server

While SHOW GRANTS may reveal remote access permissions restricted to localhost for the root user, there are methods to extend these permissions beyond the local machine.

Granting Permissions by Hostname:

To grant root access from any machine within the domain *.example.com, execute the following:

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%example.com' 
IDENTIFIED BY 'some_characters' 
WITH GRANT OPTION;
FLUSH PRIVILEGES;

Granting Permissions by IP Address:

Alternatively, access can be restricted by IP or subnet:

GRANT ALL PRIVILEGES ON *.* TO 'root'@'192.168.1.%'
    IDENTIFIED BY 'some_characters'  
    WITH GRANT OPTION;
FLUSH PRIVILEGES;

Refer to MySQL's GRANT syntax documentation for further details.

The above is the detailed content of How Can I Grant Remote Access to My MySQL Server?. 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