Home >Database >Mysql Tutorial >How to Allow MySQL Root Access from All Hosts?

How to Allow MySQL Root Access from All Hosts?

Linda Hamilton
Linda HamiltonOriginal
2024-12-06 19:44:12577browse

How to Allow MySQL Root Access from All Hosts?

Allowing Root Access from All Hosts in MySQL

To grant remote access to the MySQL root user from all hosts, follow these steps:

a) Grant Privileges

As the root user, execute the following command, replacing 'password' with your current root password:

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password';

b) Bind to All Interfaces

To allow connections from all hosts, two methods can be used:

Method 1: Commenting out bind-address

Comment out the following line in the my.cnf configuration file (typically located in /etc/mysql/my.cnf):

#bind-address = 127.0.0.1

Method 2: Using bind-address=*

You can also explicitly bind MySQL to listen on all interfaces by adding the following line to my.cnf:

bind-address = *

After making these changes, restart MySQL:

service mysql restart

To verify that MySQL is listening on all interfaces, execute the following command:

netstat -tupan | grep mysql

After completing these steps, you should be able to access the MySQL server as the root user from any host on the internet.

The above is the detailed content of How to Allow MySQL Root Access from All Hosts?. 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