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
- Log in to EGPNL
- Go to Databases → Remote MySQL
- Enter your IP address or hostname
- 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:
- Go to MySQL Databases
- Check that your user has All Privileges
- 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
- Open MySQL Workbench
- Click + to add new connection
- Enter connection name
- Set Hostname to your server address
- Set Port to 3306
- Enter username
- Click Store in Vault for password
- Click Test Connection
- 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:
- Go to Remote MySQL in EGPNL
- Enter
%as the host - 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
- Create new connection
- Set Connection Method: Standard TCP/IP over SSH
- SSH Hostname: your-server.com
- SSH Username: your SSH user
- SSH Key File: your private key (optional)
- MySQL Hostname: localhost (or 127.0.0.1)
- 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:
- Go to Remote MySQL in EGPNL
- Find the IP/host entry
- Click Delete
Was this article helpful?