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

How to Allow MySQL Root Access from All Hosts?

Linda Hamilton
Release: 2024-12-06 19:44:12
Original
519 people have browsed it

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

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

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 = *
Copy after login

After making these changes, restart MySQL:

service mysql restart
Copy after login

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

netstat -tupan | grep mysql
Copy after login

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!

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