How to Create a MySQL Database and User in cPanel
Create a MySQL database and user in cPanel, grant the right privileges, and find the database name, username, password and host your application needs to connect.

Table of Contents
- Method 1: MySQL Database Wizard (recommended)
- Method 2: MySQL Databases (manual)
- The details your application needs
- Which privileges to grant
- Working with the database: phpMyAdmin
- Common problems
- Worked example: a database for a new Laravel app
- Housekeeping: deleting and renaming
- Frequently Asked Questions
- Related reading
- Sources
In cPanel you create a database in three steps: create the database, create a database user with a strong password, and add that user to the database with the privileges it needs. The MySQL Database Wizard walks you through all three in order. Your application then connects with the database name, username, password and host (usually localhost).
Method 1: MySQL Database Wizard (recommended)
- Log in to cPanel and open Databases → MySQL Database Wizard.
- Step 1, Create a Database: enter a name, for example
shop. cPanel adds your account prefix automatically, so the full name becomes something likecpuser_shop. Click Next Step. - Step 2, Create Database Users: enter a username (also prefixed, such as
cpuser_shopuser) and use the Password Generator for a strong password. Copy the password into your password manager. Click Create User. - Step 3, Add User to the Database: tick the privileges. For most web applications such as WordPress, select ALL PRIVILEGES. Click Next Step.
- Done. Note the full database name, username and password.
Method 2: MySQL Databases (manual)
The MySQL Databases page lets you do the same steps separately:
- Create New Database: enter a name and click Create Database.
- Add New User: username and password, then Create User.
- Add User To Database: choose the user and database, click Add, then select privileges and Make Changes.
Use this page later to change passwords, add users to databases, check and repair databases, or delete them.
The details your application needs
| Setting | Value |
|---|---|
| Database name | Full name including prefix, e.g. cpuser_shop |
| Username | Full username including prefix, e.g. cpuser_shopuser |
| Password | The password you set |
| Host | localhost on most cPanel servers |
| Port | 3306 (default) |
For WordPress these go into wp-config.php as DB_NAME, DB_USER, DB_PASSWORD and DB_HOST. For Laravel they go in .env as DB_DATABASE, DB_USERNAME, DB_PASSWORD and DB_HOST.
Which privileges to grant
- Most CMSs (WordPress, Joomla) during installation and updates need broad privileges; ALL PRIVILEGES on their own database is the usual choice.
- Custom applications may run day to day with fewer privileges (SELECT, INSERT, UPDATE, DELETE) and use a separate, more privileged user for migrations.
- Never give one user access to every database in the account unless it really needs it.
See database security best practices.
Working with the database: phpMyAdmin
Open Databases → phpMyAdmin to:
- browse and edit tables;
- Import an SQL file (for migrations and restores);
- Export a backup of the database.
Large imports may hit upload limits; ask support or use the command line if available.
Common problems
| Problem | Fix |
|---|---|
| "Access denied for user" | Wrong username/password, or the user is not added to the database |
| Application cannot find the database | Missing account prefix in the database name |
| Import fails with collation errors | Replace unsupported collations; see MySQL vs MariaDB |
| Import too large for phpMyAdmin | Compress the file, split it, or ask support |
Worked example: a database for a new Laravel app
Imagine your cPanel username is acme and you are deploying a Laravel application called "orders":
- In the MySQL Database Wizard, create the database
orders. cPanel names itacme_orders. - Create the user
ordersapp, which becomesacme_ordersapp, with a generated 24-character password. - Grant ALL PRIVILEGES so that Laravel's migrations can create tables. (On a VPS you might later use a second, more limited user for day-to-day queries.)
- Put the details in the application's
.envfile:
DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=acme_orders
DB_USERNAME=acme_ordersapp
DB_PASSWORD=the-generated-password
- Run the migrations (over SSH,
php artisan migrate --force), or import a prepared SQL file through phpMyAdmin if you have no shell access. - Open phpMyAdmin and confirm the tables exist.
The same pattern works for WordPress, with the values going into wp-config.php instead.
Housekeeping: deleting and renaming
- Deleting a database in MySQL Databases removes all its data permanently. Export it first in phpMyAdmin if there is any chance you need it.
- Removing a user from a database (or deleting the user) immediately breaks any application using those credentials.
- Renaming a database is possible in MySQL Databases on recent cPanel versions; afterwards update the application's configuration with the new name.
- Remove databases and users left over from old test installs; they clutter the account and may hold data you no longer want to keep.
Frequently Asked Questions
How many databases can I create?
That depends on your hosting plan's limits.
Can I connect to the database from my computer?
Only if remote access is allowed. See how to connect to MySQL remotely.
Is it MySQL or MariaDB?
cPanel calls the section "MySQL" either way; the server may run MySQL or MariaDB. Both work for typical applications.
Related reading
Use your new database to install WordPress in cPanel. Databases are included with the ServerNeed shared hosting plans.
Databases are one part of a hosting account; see what is web hosting.
Sources
Last updated 7 October 2026



