User

Remote MySQL Access

How to allow external connections to your MariaDB database from outside the server.

Last updated 1775606400

By default, all MariaDB connections are restricted to localhost. An application running on the same server does not need remote access — use 127.0.0.1 as the host.

If you need to connect from an external machine (a local dev environment, a second server, a BI tool), you can enable remote access per database user.

Enabling Remote Access

Go to Hosting Mode → Databases → [database] → Remote Access.

Select the database user to grant remote access to, enter the IP address to allow, and click Enable. The agent grants the user access from that IP in MariaDB:

GRANT ALL PRIVILEGES ON username_dbname.* TO 'username_dbuser'@'203.0.113.45';

If you enter % as the IP, access is granted from any host.

[!WARNING] Granting access from % (any IP) exposes your database port to the internet. Anyone who obtains or guesses the credentials can connect. Always restrict to a specific IP where possible.

Connecting Remotely

Use your server's public IP address as the host. The default MariaDB port is 3306.

mysql -h YOUR_SERVER_IP -P 3306 -u username_dbuser -p username_dbname

From a PHP application on a remote server:

$pdo = new PDO(
    'mysql:host=YOUR_SERVER_IP;port=3306;dbname=username_dbname',
    'username_dbuser',
    'your-password'
);

[!NOTE] Port 3306 must be open in your server's firewall. If you're on Linode, add a firewall rule to allow TCP 3306 from the specific IP you're connecting from — not from all IPs.

Disabling Remote Access

Go to Hosting Mode → Databases → [database] → Remote Access and click Revoke next to the remote grant. The agent removes the @'ip' or @'%' grant from MariaDB. Local (localhost) access is unaffected.