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

How Can I Enable Remote Root Access to My MySQL Server?

Linda Hamilton
Linda HamiltonOriginal
2024-12-07 08:59:11370browse

How Can I Enable Remote Root Access to My MySQL Server?

Enhancing MySQL Root Access for Remote Connections

The need to enable remote root access in MySQL arises commonly when managing databases on a remote server. This comprehensive guide will walk you through the steps required to achieve this objective.

To begin, it's essential to ensure the root user has appropriate access privileges. Execute the following command as the root user, substituting 'password' with your current root password:

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

Next, you need to bind MySQL to all available network interfaces to enable connections from any host. To achieve this:

  1. Edit the MySQL configuration file. For Ubuntu 16, this file is located at /etc/mysql/mysql.conf.d/mysqld.cnf.
  2. Locate the line that starts with "bind-address" and comment it out using a "#" character:
#bind-address = 127.0.0.1
  1. Restart the MySQL service to apply the changes:
service mysql restart

To verify that MySQL is now bound to all interfaces, run the following command as root:

netstat -tupan | grep mysql

These steps should effectively allow root access to MySQL from any host on the internet. Remember that this modification affects all users with the root password, so it's crucial to secure your server adequately.

The above is the detailed content of How Can I Enable Remote Root 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