# How to create a MySQL database in cPanel

> Create a MySQL database and user in cPanel with the Database Wizard, grant the right privileges, import an .sql file in phpMyAdmin and connect your app.

Source: https://www.fasterhost.in/kb/create-a-mysql-database-in-cpanel.php · cPanel · 4 min read · updated 24 September 2026

Most PHP applications, including WordPress, Laravel and Magento, keep their data in MySQL. In cPanel a working database needs three things: the database, a user, and permission linking the two. The wizard creates all three in one pass.

## Steps

### 1. Open the MySQL Database Wizard

In cPanel, go to **Databases → MySQL Database Wizard**. Servers running MariaDB show the same screens under the same name.

### 2. Name the database

Type a short name such as `shop`. cPanel adds your account username as a prefix, so the real name becomes something like `cpuser_shop`. Write down the full name; your application needs it exactly.

### 3. Create the database user

Choose a username (it gets the same prefix) and use the **Password Generator** for a long random password. Save both. Give each application its own user, so one compromised app cannot read another's data.

### 4. Grant privileges

For a normal application, tick **ALL PRIVILEGES**. For a reporting or read-only user, tick only **SELECT**. Click **Make Changes**.

### 5. Connect your application

Use `localhost` as the database host, with the full prefixed database name, username and password. In WordPress these go in `wp-config.php` as `DB_NAME`, `DB_USER`, `DB_PASSWORD` and `DB_HOST`.

To load existing data, open **phpMyAdmin**, select the database and use **Import** with your `.sql` or `.sql.gz` file. For a file larger than the upload limit, use the cPanel **Terminal**: `mysql -u cpuser_shopuser -p cpuser_shop < dump.sql`.

## Connecting from outside the server

By default a database only accepts connections from the server itself. To connect a desktop client or a reporting tool, add your IP address in **Databases → Remote Database Access** and use the server hostname instead of `localhost`. Allow single IP addresses rather than ranges, and remove them when you are done.

## "Error establishing a database connection"

- **The prefix is missing.** The database and user names include the `cpuser_` prefix.
- **The user was never added to the database.** Check **Current Databases** in MySQL Databases; the user should be listed under Privileged Users.
- **The password is wrong.** Reset it under **Current Users** and update the app's config.
- **The host is not localhost.** Applications on the same account connect to `localhost`.

## Common questions

**How many databases can I create?**

It depends on the plan. Each plan lists its limits on the pricing page.

**What is the database host in cPanel?**

localhost, for any application running in the same hosting account.

**Is it MySQL or MariaDB?**

Our servers run MySQL or MariaDB. MariaDB is a drop-in replacement for MySQL, so applications written for MySQL work unchanged.

**How do I back up a single database?**

Export it from phpMyAdmin, or restore any earlier copy from the database backups in JetBackup.

## Related

- [How to back up and restore a website in cPanel](https://www.fasterhost.in/kb/back-up-and-restore-a-website-in-cpanel.php)
- [How to install WordPress](https://www.fasterhost.in/kb/install-wordpress.php)
- [cPanel Hosting](https://www.fasterhost.in/cpanel-hosting.php): cPanel on LiteSpeed and NVMe, served from India
- [Shared Hosting](https://www.fasterhost.in/shared-hosting.php): Fast, affordable hosting for your first site
