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

How to Enable MySQL Root Access from All Hosts?

DDD
Release: 2024-12-04 07:47:14
Original
832 people have browsed it

How to Enable MySQL Root Access from All Hosts?

Enabling MySQL Root Access from All Hosts

You have defined the root user in the MySQL user table with access restricted to specific hosts. To allow root access from any host on the internet, follow these steps:

Step 1: Grant Privileges

As the root user, execute this query, replacing 'password' with your current password:

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

Step 2: Bind to All Interfaces

a) Open the MySQL configuration file (my.cnf):

sudo nano /etc/mysql/my.cnf
Copy after login

b) Locate the line containing:

# bind-address = 127.0.0.1
Copy after login

c) Remove the leading # (hash) character to comment out the line.

d) Restart MySQL:

sudo service mysql restart
Copy after login

By default, MySQL binds to localhost only. Commenting out the bind-address line will cause it to bind to all interfaces, effectively allowing access from any host.

Verification

To check the current MySQL binding, execute:

sudo netstat -tupan | grep mysql
Copy after login

You should see an entry with a bind address of 0.0.0.0:3306, indicating that MySQL is now listening on all interfaces.

The above is the detailed content of How to Enable 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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template