How to Create a MySQL Database in cPanel
In cPanel open Databases → MySQL Databases, create the database, create a user with a saved password, then add that user to the database with ALL PRIVILEGES. Put the prefixed database name, prefixed user, password and localhost into your app’s configuration file, such as wp-config.php, and load the site to confirm.
For site owners and developers on cPanel hosting who need a database for WordPress, a CMS or a custom app.
knowledge
- Read time
- 5 min
- Sections
- 5
- Updated
- 14 Nov 2026
- Written by
- WebJi® team
Last editorial update: 14 November 2026.
What does a cPanel MySQL database consist of?
A working cPanel database is three linked items: the database, a MySQL user, and that user’s privileges on the database. None is usable alone, and all names start with your cPanel account prefix, so a database typed as “shop” is stored as account_shop.
- Database name: short and descriptive; cPanel counts each underscore as two characters toward the length limit.
- User: separate from your cPanel login and from email accounts.
- Password: cPanel does not show it again after creation, so save it in a password manager.
- Host:
localhostfor websites on the same account; see find the database hostname if your host says otherwise.
Create databases in cPanel, not with a CREATE DATABASE query in phpMyAdmin. cPanel keeps track of the databases it creates, and one made outside its tools can be missed by its backup and restore.
How do you create a database and user in MySQL Databases?
Open Databases → MySQL Databases, create the database, create a user, then add the user to the database with ALL PRIVILEGES. The page lists these blocks in order from top to bottom.
- Under Create New Database, type a name such as
shopand click Create Database, then Go Back. - Under MySQL Users → Add New User, enter a username and a generated password, then click Create User. Copy the password now.
- Under Add User To Database, select the user and the database, then click Add.
- On the privileges screen, tick ALL PRIVILEGES and click Make Changes.
- Back on the main page, check Current Databases: your user must appear under Privileged Users for that database.
A database without a privileged user cannot be used by any script, which is the commonest cause of the connection error below.
How do you use the MySQL Database Wizard instead?
The MySQL Database Wizard runs the same three steps — database, user, privileges — on consecutive screens, which is quicker for a single new site.
- Open Databases → MySQL Database Wizard, type the database name and click Next Step.
- Enter a username and a strong password, then click Create User.
- Tick ALL PRIVILEGES and click Next Step.
- Copy the full database name, user name and password from the final screen.
If the wizard says the name already exists, pick another rather than guessing at an old database. For WordPress, a one-click installer creates the database for you; see install WordPress in cPanel.
How do you connect WordPress or another app to the database?
Put the full prefixed database name, the prefixed user name, the password and localhost into the application’s configuration file. For WordPress that file is wp-config.php in the site’s folder.
define( 'DB_NAME', 'account_shop' );
define( 'DB_USER', 'account_shopuser' );
define( 'DB_PASSWORD', 'the-password-you-saved' );
define( 'DB_HOST', 'localhost' );
Edit the file in File Manager after making a backup copy (the File Manager guide shows how), save, and load the site in a private window. In phpMyAdmin the database should list tables once the installer or import has run; an empty database before installation is normal.
How do you import or export a database with phpMyAdmin?
Open phpMyAdmin from the Databases section, select the database on the left, then use Import to load a .sql or .sql.gz file or Export to download a copy. The database and its user must already exist in cPanel.
- Import: choose the file and click Import. Very large dumps can exceed upload limits; compress them or ask support to import them.
- Export: Quick export as SQL is enough for most backups before a migration or update.
- Maintenance: repair and optimise tables as described in repair and optimise a MySQL database.
For full-account copies including files, see the cPanel backup and restore guide.
How do you fix “Error establishing a database connection”?
The message means the application could not log in with the four values in its configuration file; compare each one against MySQL Databases, starting with the account prefix and the privilege row. Change one value, then reload.
| Symptom | Check |
|---|---|
| Error on a fresh install | DB_NAME and DB_USER include the account prefix |
| Error after a password change | Change Password under MySQL Users and paste the same value into wp-config.php |
| Error after creating a new user | The user is listed under Privileged Users with ALL PRIVILEGES |
| Error after moving hosts | The dump was imported into the new database; DB_HOST is localhost |
| MySQL error 1045 | Access denied: wrong user, password or source host |
| MySQL error 2002 | Cannot connect: wrong host or socket, or the database server is down |
If the page stays blank, read the PHP error log (check PHP error logs); fix the database connection error goes deeper. If 2002 persists with correct settings, email support@webji.services, because the database service itself may need attention.
How do you allow remote connections to a cPanel database?
Open Databases → Remote MySQL and add the public IP address of the computer or server that needs to connect; websites on the same account never need this. Add single addresses, not wildcards, and remove them when the work is done.
Remote MySQL does not change DB_HOST for the website, and it cannot open port 3306 if the host’s firewall blocks it. For occasional access, an SSH tunnel is safer than opening the port. On WebJi® cPanel hosting, email support@webji.services with your IP if a remote client still times out.
Frequently asked questions
How many MySQL databases can I create in cPanel?
The limit is set by your hosting plan and shown in the cPanel sidebar statistics. Each database also uses disk space from the account, so large or many databases count toward the plan’s storage.
Can one MySQL user access several databases?
Yes, by adding the same user to each database. It is safer to give every site its own user, so a leaked password from one site cannot read another site’s data.
How do I rename a database in cPanel?
MySQL Databases offers a Rename action next to each database. Renaming changes the name the application must use, so update the configuration file straight after, and take an export first in case anything goes wrong.
What happens if I delete a database?
All its tables and data are removed immediately, and any site using it shows a connection error. Export it first; recovery afterwards depends on whether a backup exists, so check your cPanel full backup schedule.
Last editorial update: 15 November 2026.
Ready to get started with WebJi®?
Join 12,000+ businesses across India and overseas. INR pricing, 18% GST shown before payment and 24/7 email support in Hindi and English — average first reply under 60 minutes.