When You Need Remote Access

Remote database access allows you to connect to your MySQL database from:

  • Local development environment (XAMPP, MAMP, Docker)
  • Desktop database tools (MySQL Workbench, DBeaver, Sequel Pro)
  • Other servers or cloud applications
  • Automated scripts and backup tools
Security Note: Remote MySQL access opens a potential security risk. Only enable it when necessary and always use strong passwords.

Enabling Remote Access

Step 1: Add Remote Host

  1. Log in to EGPNL
  2. Go to DatabasesRemote MySQL
  3. Enter your IP address or hostname
  4. Click Add Host
Find Your IP: Visit whatismyipaddress.com to find your current public IP.

Step 2: Configure Database User

Ensure your database user has the correct permissions:

  1. Go to MySQL Databases
  2. Check that your user has All Privileges
  3. Or create a dedicated remote user

Connection Settings

Setting Value
Hostname Your server IP or yourdomain.com
Port 3306 (default MySQL port)
Database your_database_name
Username your_database_user
Password your_database_password

Connecting with MySQL Workbench

  1. Open MySQL Workbench
  2. Click + to add new connection
  3. Enter connection name
  4. Set Hostname to your server address
  5. Set Port to 3306
  6. Enter username
  7. Click Store in Vault for password
  8. Click Test Connection
  9. Click OK to save

Connecting with Command Line

# Basic connection
mysql -h your-server.com -P 3306 -u username -p database_name

# Example
mysql -h server.egphp.com -P 3306 -u mysite_user -p mysite_db

Connecting with PHP (Remote Application)

<?php
$host = 'your-server.com';  // Remote server hostname
$port = 3306;
$database = 'your_database';
$username = 'your_user';
$password = 'your_password';

// PDO Connection
try {
    $pdo = new PDO(
        "mysql:host=$host;port=$port;dbname=$database;charset=utf8mb4",
        $username,
        $password,
        [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]
    );
    echo "Connected successfully!";
} catch (PDOException $e) {
    echo "Connection failed: " . $e->getMessage();
}
?>

Allow All Hosts (Wildcard)

To allow connections from any IP address:

  1. Go to Remote MySQL in EGPNL
  2. Enter % as the host
  3. Click Add Host
Not Recommended: Allowing all hosts (%) is a security risk. Only use for testing and remove afterward. Use specific IPs whenever possible.

SSH Tunnel (Most Secure)

For maximum security, connect through an SSH tunnel:

Command Line SSH Tunnel

# Create tunnel
ssh -L 3307:localhost:3306 user@your-server.com

# In another terminal, connect via tunnel
mysql -h 127.0.0.1 -P 3307 -u dbuser -p database_name

MySQL Workbench SSH

  1. Create new connection
  2. Set Connection Method: Standard TCP/IP over SSH
  3. SSH Hostname: your-server.com
  4. SSH Username: your SSH user
  5. SSH Key File: your private key (optional)
  6. MySQL Hostname: localhost (or 127.0.0.1)
  7. Enter database credentials
Why SSH Tunnel? SSH tunnels encrypt all traffic and don't require opening MySQL port 3306 to the internet.

Troubleshooting

Connection Refused

  • Verify your IP is added to Remote MySQL
  • Check if your IP has changed (dynamic IP)
  • Confirm port 3306 is open on your firewall

Access Denied

  • Verify username and password
  • Check user has remote access privileges
  • Ensure database name is correct

Timeout Errors

  • Check network/firewall blocking port 3306
  • Try using SSH tunnel instead
  • Verify server is accepting connections

Remove Remote Access

When you no longer need remote access:

  1. Go to Remote MySQL in EGPNL
  2. Find the IP/host entry
  3. Click Delete