Home Cloud Serevrs Set Up a Remote MySQL Database on a Windows VPS

Set Up a Remote MySQL Database on a Windows VPS

Last updated on Feb 13, 2025

Hosting a remote MySQL database on a Windows VPS allows you to store, manage, and access databases from external applications, websites, or game servers. This guide will walk you through installing, configuring, and securing a remote MySQL server on a Windows Server VPS.


📌 Prerequisites

  • A Windows Server VPS (2016, 2019, or 2022) from VolticHost

  • Administrator access

  • Ports 3306 (TCP) open in the firewall

  • MySQL Community Server installed


1️⃣ Install MySQL Server on Windows VPS

  1. Download MySQL Community Server from:
    👉 https://dev.mysql.com/downloads/installer/

  2. Run the installer and choose "Server Only" when prompted.

  3. Click Next and complete the installation.

MySQL Server is now installed!


2️⃣ Configure MySQL for Remote Access

  1. Open MySQL Configuration File (my.ini):

    notepad C:\ProgramData\MySQL\MySQL Server X.X\my.ini
    
    
  2. Find the line:

    bind-address = 127.0.0.1
    
    
  3. Change it to:

    bind-address = 0.0.0.0
    
    
  4. Save the file and restart MySQL:

    net stop mysql
    net start mysql
    
    

Your MySQL server is now accessible remotely!


3️⃣ Create a Remote MySQL User

  1. Open Command Prompt (Admin) and log into MySQL:

    mysql -u root -p
    
    
  2. Create a new user with remote access (replace YourPassword with a strong password):

    CREATE USER 'remote_user'@'%' IDENTIFIED BY 'YourPassword';
    GRANT ALL PRIVILEGES ON *.* TO 'remote_user'@'%' WITH GRANT OPTION;
    FLUSH PRIVILEGES;
    
    
  3. Exit MySQL:

    exit
    
    

Your MySQL user is now set up for remote access!


4️⃣ Open MySQL Port 3306 in Windows Firewall

  1. Open Windows Defender Firewall (Win + R, type wf.msc, press Enter).

  2. Click Advanced SettingsInbound RulesNew Rule.

  3. Select Port, then click Next.

  4. Choose TCP, enter 3306, then click Next.

  5. Select Allow the connection, then click Next again.

  6. Apply to Domain, Private, and Public networks.

  7. Name the rule MySQL Remote Access and click Finish.

Your MySQL server is now accessible from external connections!


5️⃣ Test the Remote MySQL Connection

From Another Server or PC

  1. Open Command Prompt on a remote machine.

  2. Connect to the MySQL server using:

    mysql -u remote_user -p -h Your-VPS-IP
    
    
  3. Enter the password when prompted.

If the connection is successful, MySQL will return:

Welcome to the MySQL monitor...

Your remote MySQL database is working!


6️⃣ Secure Your Remote MySQL Server (Recommended)

Limit Remote Access to Specific IPs

Instead of allowing all IPs (%), restrict MySQL access to a specific IP (e.g., 192.168.1.100):

CREATE USER 'remote_user'@'192.168.1.100' IDENTIFIED BY 'YourPassword';
GRANT ALL PRIVILEGES ON *.* TO 'remote_user'@'192.168.1.100' WITH GRANT OPTION;
FLUSH PRIVILEGES;

Disable Root Remote Access

REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'root'@'%';

Enable MySQL Firewall Protection

Use Fail2Ban or Windows Firewall rules to prevent brute-force attacks.

Your remote MySQL server is now more secure!


🎉 Conclusion

You've successfully set up a remote MySQL database on a Windows VPS! Your applications, websites, and game servers can now connect to the centralized database remotely. 🚀

For more assistance, contact VolticHost Support.