Guides

Fix real problems quickly with simple and practical solutions.
Linux Guides

How to Allow Remote MySQL Connection

Fix HeidiSQL connection issues by enabling external MySQL access in minutes.

Before you start

You need root or sudo access to the server.
MySQL must already be installed and running.
Port 3306 must be open in firewall or cloud settings.

Step-by-step instructions

1. Create remote MySQL user

Create a user that can connect from any IP.

SQL
CREATE USER 'root'@'%' IDENTIFIED BY 'yourpassword';

2. Grant privileges

SQL
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%';
FLUSH PRIVILEGES;

3. Update bind-address

Edit MySQL configuration file.

vi /etc/mysql/my.cnf
bind-address = 0.0.0.0

4. Restart MySQL

service mysql restart

Common issues

Port 3306 blocked

Make sure firewall or cloud security allows MySQL port.

bind-address not changed

MySQL will still block external access if bind-address is 127.0.0.1.

Wrong user host

User must be created with '%' to allow remote access.

About this guide

This guide shows how to allow remote MySQL access so you can connect from tools like HeidiSQL. By default, MySQL blocks external connections, so you need to update user permissions and configuration settings.

How to follow this guide

  1. Create a MySQL user that allows remote connections.
  2. Grant proper privileges to the user.
  3. Update MySQL configuration bind-address setting.
  4. Restart MySQL service.
  5. Check firewall and port settings if connection fails.

Why use this method?

Remote MySQL access allows you to manage your database from external tools like HeidiSQL, making development and server management much easier.

Frequently Asked Questions

Why is MySQL not accessible remotely?

MySQL blocks external access by default using bind-address and user host restrictions.

Is it safe to allow root remote access?

It is not recommended. Creating a separate user with limited privileges is safer.

What port does MySQL use?

MySQL uses port 3306 by default.

What if I still cannot connect?

Check firewall rules, cloud security groups, and ensure port 3306 is open.