html
When configuring remote MySQL connections, knowing your database server's IP address is crucial. For x10hosting users (x10.bz) using cPanel X with PHPMyAdmin, this information is readily available through multiple methods.
Navigate to your PHPMyAdmin dashboard through cPanel:
1. Login to cPanel
2. Open PHPMyAdmin from Databases section
3. Check the 'Server' tab information
4. Look for 'Server:' value containing hostname/IP
Create a PHP connection script to display connection details:
<?php
$link = mysqli_connect("localhost", "username", "password");
if (!$link) {
die('Could not connect: ' . mysqli_error());
}
echo 'Connected to: ' . mysqli_get_host_info($link);
mysqli_close($link);
?>
Execute this SQL query in PHPMyAdmin:
SELECT @@hostname AS host, @@port AS port;
- Ensure remote MySQL access is enabled in cPanel's "Remote MySQL" tool
- Add your connecting IP to the access list
- Verify firewall rules allow port 3306 traffic
Common connection strings for different languages:
# Python example
import mysql.connector
mydb = mysql.connector.connect(
host="your_mysql_host_ip",
user="yourusername",
password="yourpassword"
)
// Node.js example
const mysql = require('mysql');
const connection = mysql.createConnection({
host: 'your_mysql_host_ip',
user: 'yourusername',
password: 'yourpassword'
});
When working with x10hosting or similar shared hosting providers, the MySQL server typically runs on a separate host from your web server. To establish remote connections, you'll need to identify the actual IP address rather than using "localhost".
Login to your phpMyAdmin interface and look for this information in multiple places:
-- Check server variables
SHOW VARIABLES WHERE Variable_name = 'hostname';
-- Alternative query for host IP
SHOW VARIABLES LIKE 'bind_address';
You'll typically see either the actual IP or a hostname that resolves to your MySQL server.
Navigate to "MySQL Databases" in cPanel and check:
- The "Current Hosts" section
- Connection strings provided in the interface
- Any remote MySQL configuration options
Once you have the hostname, you can resolve it to an IP:
# Linux/Mac
nslookup mysql-hostname.x10.bz
# or
ping mysql-hostname.x10.bz
# Windows
nslookup mysql-hostname.x10.bz
Here's a PHP script to test your remote connection (save as test_mysql.php):
<?php
$host = 'mysql_ip_or_hostname';
$user = 'your_username';
$pass = 'your_password';
$db = 'your_database';
try {
$conn = new PDO("mysql:host=$host;dbname=$db", $user, $pass);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
echo "Connected successfully to MySQL server at $host";
} catch(PDOException $e) {
echo "Connection failed: " . $e->getMessage();
}
?>
x10hosting typically uses one of these patterns:
- mysqlXX.x10hosting.com (where XX is a server number)
- A dedicated IP in their MySQL server range
- Sometimes requires SSH tunneling for external access
If connections fail after getting the IP:
- Verify the IP is added in cPanel's "Remote MySQL" section
- Check for firewalls (both x10's and your local network)
- Test with different ports (usually 3306)
- Verify your user has remote connection privileges
-- Grant remote access (run in phpMyAdmin)
GRANT ALL PRIVILEGES ON your_db.* TO 'user'@'your_local_ip' IDENTIFIED BY 'password';
FLUSH PRIVILEGES;