Granting Remote Root Access in MySQL
You have encountered an issue where you cannot access MySQL's root user from your personal computer, despite granting '%'-based access to the server. To resolve this issue, follow these steps:
As the root user in MySQL, execute the following command to grant all privileges to the root user from any host (%):
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password';
You need to allow MySQL to listen on all network interfaces. Comment out the following line in /etc/mysql/mysql.conf.d/mysqld.cnf (or /etc/mysql/my.cnf on older versions):
#bind-address = 127.0.0.1
Restart MySQL to apply the changes:
service mysql restart
Check that MySQL is now listening on all interfaces by running the following command:
netstat -tupan | grep mysql
If the issue persists, ensure that your firewall allows connections to port 3306 from the external IP addresses you are trying to connect from.
The above is the detailed content of How Can I Grant Remote Root Access to My MySQL Server?. For more information, please follow other related articles on the PHP Chinese website!