We talking about Cloud
Web Hosting & Cloud Services
Celebrate the power and freedom of Open Source
with Open Source Cloud Servers starting at only £10/mo £5/mo.
Web Hosting & Cloud Services
Celebrate the power and freedom of Open Source
with Open Source Cloud Servers starting at only £10/mo £5/mo.
To connect to a MySQL database, your application needs the correct database hostname, database name, username and password. The database user must also have permission to access that database.
Applications such as WordPress, Joomla and WHMCS store these details in a configuration file. If a connection fails after a migration or password change, those settings are a good place to start.
This guide explains how to connect to a MySQL database through your application, check permissions in cPanel and troubleshoot common problems.
Before editing anything, download a backup of the configuration file and store it securely outside your website’s public directory.
Common locations include:
| Application | Typical configuration file |
|---|---|
| WordPress | wp-config.php in the WordPress installation directory |
| Joomla | configuration.php in the installation directory |
| WHMCS | configuration.php in the installation directory |
Custom applications may use environment variables, a .env file or another configuration method. Follow the application’s documentation rather than creating a new file based only on its name.
For related guidance, see Location of Script Configuration Files.
Keep configuration files private. They can contain database credentials and other sensitive settings.
You usually need these four values:
| Setting | What to enter |
|---|---|
| Database hostname | The hostname supplied by your hosting provider |
| Database name | The full name of the database your application uses |
| Database username | A database user assigned to that database |
| Database password | The password belonging to that database user |
On many cPanel accounts, database names and usernames include an account prefix:
Database name: account_website
Database user: account_siteuser
Copy the complete names shown in cPanel. Do not assume the prefix is enabled or that it matches an old hosting account.
localhost?No. Use localhost only when your hosting provider specifies it.
A local database service may use localhost, while a separate database server requires its own hostname. Your application may also need a port or socket setting.
Do not replace localhost with 127.0.0.1 simply because a connection fails. Depending on the client, those values can use different connection methods.
In cPanel, open Databases → Manage My Databases. Older versions may label this interface MySQL Databases.
If you are setting up a new application, cPanel’s Database Wizard can guide you through creating the database, creating a user and assigning access.
For an existing setup:
Use the permissions specified by the application’s installation documentation. An installer or updater may need permissions that a read-only reporting tool does not.
Creating a user does not automatically give it access to every database.
For details, see cPanel’s Manage My Databases documentation.
To connect to a MySQL database, update the application’s existing settings with the values you have confirmed. Preserve the file’s syntax and avoid adding duplicate settings.
In wp-config.php, find the existing database constants:
define( 'DB_NAME', 'account_website' );
define( 'DB_USER', 'account_siteuser' );
define( 'DB_PASSWORD', 'REPLACE_WITH_YOUR_DATABASE_USER_PASSWORD' );
define( 'DB_HOST', 'localhost' );
These are placeholders. Replace them with your actual details and use the hostname supplied by your provider.
A few checks help prevent simple mistakes:
See the official WordPress configuration guide for application-specific details.
Use a database user created for the application rather than relying on your main hosting-account credentials.
A dedicated user makes access easier to manage and limits the databases that those credentials can reach.
If you change a database user’s password, update every application that uses that user. Changing the password in cPanel does not rewrite your application configuration files.
After saving the configuration, test the application itself.
For a website, check:
Use a test or staging environment for changes that could affect orders, payments or customer records.
If your account provides a MySQL client and terminal access, you can test the credentials with:
mysql -h DATABASE_HOST -u DATABASE_USER -p DATABASE_NAME
Replace the placeholders with your settings. Enter the password when prompted; do not place it directly in the command.
Once connected, a simple read-only check is:
SELECT DATABASE(), CURRENT_USER();
Exit with:
EXIT;
A successful terminal connection is useful evidence, but the application can still fail if it uses different credentials, runs from another server or lacks the required database driver.
If the application and database run on different servers, you may need remote access.
In cPanel, the relevant interface is Databases → Remote Database Access. Older versions call it Remote MySQL.
Where your hosting plan supports it:
Adding an access host does not replace the need for valid credentials and database privileges. It also does not automatically configure every firewall or network setting.
Avoid granting access from all addresses when a specific host will do. If direct remote access is unavailable, ask your provider about supported alternatives.
See cPanel’s Remote Database Access documentation.
The wording of the error usually helps you narrow down the problem.
| Error or symptom | What to check first |
|---|---|
| Access denied for user | Username, password, permitted connection host and authentication requirements |
| Unknown database | Database name, account prefix and whether the database exists |
| Connection refused | Hostname, port, service availability and network restrictions |
| Connection timed out | Routing, firewall rules, remote-access permissions and destination availability |
| Permission denied for a query | Privileges assigned to the database user |
| WordPress reports a database connection error | wp-config.php, database availability and the underlying error logs |
Check whether the user is assigned to the intended database.
Return to Manage My Databases, review the user-to-database association and apply the permissions required by the application. Keep a record of the original grants before changing them.
Do not assume this is caused by an old cPanel bug. Incorrect assignments, migrations and permission changes are more useful starting points for investigation.
A successful connection does not prove that the application is using the right database.
Check:
Do not reinstall the application over existing data simply to test the connection.
Database credentials often differ between hosting accounts. After moving a website:
Do not rely on the old claim that a database username can only change when the cPanel username changes. Available naming and renaming options depend on the server configuration and permissions.
Not necessarily. A dedicated database user has its own credentials. Use the password belonging to the user named in your application’s configuration.
phpMyAdmin lets you inspect and manage databases through cPanel. However, opening a database there does not prove that your application’s separate credentials are correct.
Usually, no. First check the existing hostname, database name, credentials and permissions. Creating another database will not repair an incorrect setting and may leave the application connected to an empty database.
Share the relevant error message and configuration details with passwords and other secrets removed. If support needs additional access, use the provider’s approved secure process.
Contact DigitalBerg support with the affected domain, application name, exact error and whether the connection is local or remote.
Include when the problem began and any recent migration, password or configuration changes. Do not include your database password in the message.

Script Configuration: 7 Essential Tips for Safe Edits
