When connecting a website to a MySQL database on a standard 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.
Important: Standard Web Hosting and Reseller Hosting support local database connections only. Remote MySQL connections through port 3306 are not available. If an external application, server, computer, or service needs to connect directly to your database, you will need DEV Hosting or VPS Hosting.
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 for local connections only, unless the application detects it automatically
Port 3306 is the standard MySQL port, but including it in your website configuration does not enable remote database access. On standard hosting, the connection must originate from within the same hosting account and use localhost.
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 instead of 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 websites running directly within the hosting account, including WordPress, Joomla, Drupal, WHMCS, and custom PHP websites, localhost is the correct MySQL hostname.
Remote MySQL Access Through Port 3306
Remote MySQL access through port 3306 is not available with Standard Web Hosting or Reseller Hosting.
This means you cannot connect directly to a standard hosting database from:
-
A desktop database application
-
Another web server
-
A remotely hosted application
-
An external script or service
-
A development computer
-
A third-party reporting platform
Blocking external connections to port 3306 helps protect shared servers and customer databases from unauthorized login attempts, automated attacks, and unnecessary public exposure.
If your project requires a direct remote database connection, choose DEV Hosting or VPS Hosting.
Applications That Require Remote MySQL
Some projects require an external server, application, or development environment to connect directly to MySQL through port 3306. Examples include:
-
Custom applications hosted outside the hosting account
-
External inventory systems
-
Business intelligence tools
-
Remote reporting applications
-
Development environments
-
Multi-server applications
-
Database synchronization systems
These configurations require DEV Hosting or VPS Hosting.
These hosting options provide the additional control needed for:
-
Remote MySQL connections through port 3306
-
Allowed remote IP addresses
-
Firewall rules
-
Database user permissions
-
Server security policies
-
Application performance and resource allocation
For security, remote MySQL access should only be permitted from trusted IP addresses. Opening MySQL to every public IP address is strongly discouraged.
Managing Databases on Standard Hosting
Standard Web Hosting and Reseller Hosting customers can manage MySQL databases securely 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 locally hosted 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 on Standard Web Hosting or Reseller Hosting. These plans only support local MySQL connections through localhost.
Need Remote MySQL Access?
If an external application, server, development computer, or third-party service needs to connect directly to MySQL through port 3306, you will need DEV Hosting or VPS Hosting.
Submit a support ticket with information about your application, expected database usage, and the IP addresses that require access. We can recommend the right hosting option and help you secure the connection.