Home >Database >Mysql Tutorial >How to Allow Remote Connections to My MySQL Database?

How to Allow Remote Connections to My MySQL Database?

Linda Hamilton
Linda HamiltonOriginal
2024-12-31 10:41:15302browse

How to Allow Remote Connections to My MySQL Database?

How to Enable Remote MySQL Connectivity

Introduction

Remote connectivity to MySQL allows external sources to establish connections with your local database. By default, remote connections are disabled, particularly for root users. This article provides a detailed solution to enable remote MySQL connections.

How to Enable Remote Connections

1. Grant Access for Remote Users

  • Execute the following SQL command locally:

    GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;
  • Run this command:

    FLUSH PRIVILEGES;

2. Edit my.cnf File

  • Locate the my.cnf file (typically in /etc/mysql/my.cnf on Unix/OSX or C:Program FilesMySQLMySQL Server 5.5my.ini on Windows).
  • Find the line:

    bind-address = 127.0.0.1
  • Comment it out by adding a "#" at the beginning of the line:

    #bind-address = 127.0.0.1

3. Restart MySQL Server

  • Restart the MySQL server by stopping and starting it to apply the changes.

The above is the detailed content of How to Allow Remote Connections to My MySQL Database?. 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