When connecting a website or application to a MySQL database on a cPanel hosting account, use the following database hostname:
localhost
This tells your website to connect to the MySQL server running on the same hosting server as your cPanel account.
Common MySQL Connection Settings
Most website applications will ask for the following database details:
Database Host: localhost
Database Name: Your full cPanel database name
Database User: Your full cPanel database username
Database Password: The password assigned to the database user
Database Port: 3306, unless the application automatically detects it
Your database name and username usually include your cPanel username as a prefix.
For example:
Database Name: accountname_wordpress
Database User: accountname_wpuser
You can create and manage databases from:
cPanel > MySQL Databases
You can also use the MySQL Database Wizard to create a database, create a database user, and assign the correct permissions.
Why You Should Use Localhost
Using localhost keeps the database connection inside the hosting server rather than sending it across the public internet.
This provides several benefits:
-
Faster database connections
-
Lower latency
-
Better security
-
No external MySQL port exposure
-
Fewer connection and firewall issues
For most websites, including WordPress, Joomla, Drupal, WHMCS, and custom PHP applications, localhost is the correct MySQL hostname.
Remote MySQL Access
Remote MySQL access is not available on our shared hosting or reseller hosting servers.
This means you cannot connect directly to a shared hosting MySQL database from:
-
A desktop database application
-
Another web server
-
A remote application
-
An external script
-
A development computer
-
A third-party reporting platform
Blocking remote MySQL access helps protect the server and customer databases from unauthorized login attempts, automated attacks, and unnecessary public exposure.
Applications That Require Remote MySQL
Some projects require an external server or application to connect directly to MySQL. Examples include:
-
Custom software hosted on another server
-
External inventory systems
-
Business intelligence tools
-
Remote reporting applications
-
Development environments
-
Multi-server applications
-
Database synchronization systems
These configurations require a custom VPS or dedicated server.
A VPS or dedicated server gives you control over:
-
MySQL remote access settings
-
Firewall rules
-
Allowed IP addresses
-
MySQL ports
-
Database user permissions
-
Server security policies
-
Performance and resource allocation
For security, remote MySQL access should only be allowed from trusted IP addresses. Opening MySQL to all public IP addresses is strongly discouraged.
Remote Database Management
Shared hosting customers can manage MySQL databases through cPanel using phpMyAdmin.
phpMyAdmin allows you to:
-
Browse database tables
-
Import and export databases
-
Run SQL queries
-
Edit database records
-
Repair and optimize tables
-
Review database structure
You can access it from:
cPanel > phpMyAdmin
Troubleshooting MySQL Connection Errors
If your website cannot connect to MySQL, verify the following:
-
The database hostname is set to localhost.
-
The database name is entered correctly.
-
The database username includes the cPanel prefix.
-
The database password is correct.
-
The database user has been assigned to the database.
-
The database user has the required permissions.
-
The application configuration file contains the correct credentials.
A common mistake is creating a database and user without assigning the user to the database. In cPanel, open MySQL Databases, locate Add User to Database, select the correct database and user, and grant the required privileges.
WordPress MySQL Configuration
WordPress stores its database connection settings inside the wp-config.php file.
A typical configuration looks like this:
define('DB_NAME', 'accountname_wordpress');
define('DB_USER', 'accountname_wpuser');
define('DB_PASSWORD', 'your-database-password');
define('DB_HOST', 'localhost');
Do not change DB_HOST to your domain name, server hostname, or IP address unless you are using a custom server configuration specifically designed for remote database access.
Need Remote MySQL Access?
Remote MySQL access requires a custom VPS or dedicated server. Submit a support ticket with details about your application, expected database usage, and the IP addresses that need access. We can recommend a suitable server configuration and help secure the connection.