WordPress: Create a MySQL Database in cPanel + Connect It in wp-config.php
For WordPress, the safest approach is to create a database and user using the MySQL® Database Wizard, because cPanel guides you step-by-step through the full flow: database → user → privileges.
1) Create the database and user (recommended: MySQL Database Wizard)
- Log in to cPanel → open Databases → MySQL® Database Wizard
- Create a database (example name: wp)
- Create a database user (example name: wpuser)
- Generate a strong password (Password Generator) and save it securely
- On the privileges screen, select ALL PRIVILEGES and finish
This workflow creates the database, creates the user, and assigns privileges in one guided process.
2) Important: the prefix (full database/user name)
cPanel typically adds a prefix (your cPanel username). That means the real names will look like:
- DB Name: CPANELUSER_wp
- DB User: CPANELUSER_wpuser
In your application, always use the full names exactly as shown in cPanel (including the prefix).
3) Enter DB values in WordPress (wp-config.php)
In wp-config.php, set these four parameters: DB_NAME, DB_USER, DB_PASSWORD, DB_HOST.
- DB_HOST is most commonly localhost
Example (replace with your real values):
define('DB_NAME', 'CPANELUSER_wp');
define('DB_USER', 'CPANELUSER_wpuser');
define('DB_PASSWORD', 'YOUR_STRONG_PASSWORD');
define('DB_HOST', 'localhost');
4) If WordPress shows a database error
- Error establishing a database connection → double-check DB_NAME/DB_USER (with prefix), password, and DB_HOST.
- Access denied for user → usually missing privileges or an incorrect password (make sure ALL PRIVILEGES were assigned).
OpenCart: Create a MySQL Database in cPanel + Enter DB Details (config.php and admin/config.php)
In OpenCart, database credentials are typically stored in two files, and they must match in both places:
- config.php (root)
- admin/config.php
1) Create database/user and assign privileges
The process is the same as WordPress (use the Wizard). If you do it manually, make sure the user is added to the database and then grant privileges (including ALL PRIVILEGES if the app needs full access).
2) Enter DB parameters in OpenCart
In both files (config.php and admin/config.php), set:
- DB_HOSTNAME – usually localhost
- DB_USERNAME – user (with prefix)
- DB_PASSWORD – password
- DB_DATABASE – database (with prefix)
Example (same in both files):
define('DB_HOSTNAME', 'localhost');
define('DB_USERNAME', 'CPANELUSER_shopuser');
define('DB_PASSWORD', 'YOUR_STRONG_PASSWORD');
define('DB_DATABASE', 'CPANELUSER_shop');
3) Most common OpenCart issues
- Only one file was updated → update both root config.php and admin/config.php.
- Prefix missing → use CPANELUSER_name, not just “shop”.
- Access denied → add the user to the database and grant ALL PRIVILEGES.
Custom DB setup: separate DB config file / overrides (when the project doesn’t read standard files)
Some projects store DB settings in a separate custom config file (or an .env). In that case, changing only wp-config.php or OpenCart config.php may have no effect.
1) How to recognize a custom DB configuration
- The config file contains require / include statements loading another file (e.g., db.php, config-db.php)
- DB constants/values are not where you expect, or are clearly overridden
- There are dedicated config folders (e.g., storage/config, system/config, private)
2) What the custom DB config must contain
- host (localhost or 127.0.0.1)
- database (with prefix)
- username (with prefix)
- password
3) Rule: edit the file that is actually loaded
If a custom DB file is included via require/include, that file is the “source of truth.” Update it there, then verify whether a separate admin config exists (OpenCart often has its own admin/config.php).
Option: ticket for SSH access and dump upload/import (professional and fastest)
When the SQL dump is large or browser imports are unstable, best practice is to perform a server-side import (SSH/CLI). If you want GoHost to assist with upload/import, open a ticket and request SSH access or an assisted database import.
1) Open a ticket
Link: https://gohost.mk/submitticket.php
2) Ticket text (copy/paste)
- Subject: Request for SSH access / DB import (SQL dump)
- Domain/site: example.com
- cPanel username: CPANELUSER
- Requested action: Please enable SSH access (or perform the import) for MySQL dump upload and import into the database.
- Database name (with prefix): CPANELUSER_wp (or CPANELUSER_shop)
- DB user (with prefix): CPANELUSER_wpuser (or CPANELUSER_shopuser)
- File: dump.sql or dump.sql.gz
- Size: ___ MB/GB
- Do you also need file upload: public_html (yes/no)
- Preferred time: when it should be executed (today/tomorrow, time window)
3) Alternative: import via phpMyAdmin (if the dump is smaller)
If the dump is small enough, you can import it via phpMyAdmin:
- cPanel → phpMyAdmin
- Select the database (left panel) → Import
- Upload .sql or .sql.gz → Start
4) Mini checklist before opening a ticket or running an import
- The database exists
- The user exists
- The user is added to the database
- ALL PRIVILEGES are granted (if the application needs full access)
- WordPress/OpenCart config files contain the correct values (with prefix)