Enabling Remote Connections and Obtaining Connection Details for Your MySQL Database

Prerequisites

Step-by-Step Guide

1. Edit MySQL Configuration File

  1. Locate the MySQL configuration file (my.ini). By default, it is located in the MySQL installation directory, e.g., C:\ProgramData\MySQL\MySQL Server 8.0\my.ini.
  2. Open my.ini in a text editor like Notepad.
  3. Find the line starting with bind-address and change its value to 0.0.0.0. If the line doesn’t exist, add it under the [mysqld] section:
    [mysqld]
    bind-address = 0.0.0.0
  4. Save the changes and restart the MySQL service:
    net stop mysql
    net start mysql

2. Grant Remote Access to a User

  1. Open the MySQL command line client or any MySQL client tool.
  2. Log in as the root user or any user with sufficient privileges:
    mysql -u root -p
  3. Grant remote access to a user:
    GRANT ALL PRIVILEGES ON database_name.* TO 'user_name'@'%' IDENTIFIED BY 'password';
    FLUSH PRIVILEGES;

3. Configure Windows Firewall

  1. Open Windows Firewall with Advanced Security (wf.msc).
  2. Click on Inbound Rules and then New Rule.
  3. Select Port and click Next.
  4. Select TCP and specify the port number 3306.
  5. Choose Allow the connection and proceed.
  6. Select when the rule applies (e.g., Domain, Private, Public).
  7. Give the rule a name (e.g., MySQL Port 3306) and finish the wizard.

4. Verify Remote Connection

  1. From a remote machine, use the MySQL client to connect to the MySQL server:
    mysql -u user_name -h server_ip_address -p

Troubleshooting

Obtaining Connection Details

Once you have enabled remote access and verified the connection, you will need the following details to connect your MySQL database to the web app:

Ask Database