Remote MySQL access lets an application on another computer use a database server. An administrator must allow the intended source, configure the database listener and provide an account with the required permissions.

Prepare restricted access

Identify the client’s source IP as the database server sees it, including any NAT gateway. Permit only that source through the server and provider firewalls. Use a private connection or approved encrypted access rather than opening the database to everyone.

On a cPanel-managed service, use its supported database-access interface where appropriate so manual changes do not conflict with account management.

Create an authorised account

Connect locally using the server’s approved database administrator authentication method. Socket authentication without a password prompt can be intentional; do not change it merely because no prompt appeared.

For MySQL, create the account separately from granting permissions. This example uses a documentation-only source address and must be replaced:

CREATE USER 'remote_user'@'198.51.100.25'
  IDENTIFIED BY 'replace-with-a-unique-password' REQUIRE SSL;
GRANT SELECT, INSERT, UPDATE, DELETE ON `account_database`.*
  TO 'remote_user'@'198.51.100.25';

Choose privileges according to the application. Do not grant administrator access or use % simply to make a failed connection work. Configure the actual database name, reachable listener and supported TLS certificates.

Test from the intended client

A MySQL client that supports certificate verification can connect using:

mysql --host=database.example.com --user=remote_user --password --ssl-mode=VERIFY_IDENTITY --ssl-ca=/path/to/ca.pem account_database

Replace the hostname, CA file and database with the real values. The certificate must match the hostname. MariaDB clients use different TLS options, so follow their matching documentation.

Confirm the account can perform only its required operations. Remove the remote grant and firewall allowance when they are no longer needed.