How to Create a MySQL Database and User in cPanel
Most dynamic websites, such as WordPress, WooCommerce, Joomla or custom PHP applications, need a database to store their content. This guide shows you how to create a MySQL database and user in cPanel, how to give the user the right privileges, how to use the database details in wp-config.php, and how to import or export a database with phpMyAdmin.
Before you start
- Log in to your cPanel account. If you are not sure how, see how to log in to cPanel.
- Prepare a strong password for the database user (or use the password generator in cPanel).
- Note that cPanel automatically adds your cPanel username as a prefix to the database and user names, for example
cpuser_shop.
Method 1: Using the MySQL Database Wizard (easiest)
- In cPanel, go to the Databases section and click MySQL® Database Wizard.
- Step 1 – Create a Database: type a short name for the database (for example
shop) and click Next Step. - Step 2 – Create Database Users: enter a username and a strong password (you can click Password Generator). Save the password somewhere safe, then click Create User.
- Step 3 – Add User to the Database: tick ALL PRIVILEGES and click Next Step. Most applications such as WordPress need all privileges to install and update correctly.
- Step 4 – Complete the task: cPanel confirms that the database and user were created and linked.
The Database Wizard in pictures
Open Database Wizard (1) in the Databases section.
Step 1: write the database name (1) and click Next Step (2).
Step 2: write the user name (1) and a strong password (2), or use Password Generator (3), then click Create User (4).
Step 3: tick ALL PRIVILEGES (1) and click Make Changes (2).
The wizard confirms that the user was added to the database.
Method 2: Using MySQL Databases manually
This page is called MySQL® Databases (in some newer cPanel versions it may appear as Manage My Databases). Use it when you want to manage existing databases or link an existing user to a new database.
- Under Create New Database, type the name and click Create Database.
- Scroll down to MySQL Users > Add New User, enter the username and password, then click Create User.
- Under Add User To Database, choose the user and the database, then click Add.
- On the privileges screen, tick ALL PRIVILEGES and click Make Changes.
On the Manage My Databases page you create a database (1), create a user (2, 3) and add the user to the database (4, 5, 6):
Using the database in wp-config.php
If you are setting up WordPress manually or moving a site, open wp-config.php from File Manager and update these lines with the full names (including the prefix):
define( 'DB_NAME', 'cpuser_shop' );
define( 'DB_USER', 'cpuser_shopuser' );
define( 'DB_PASSWORD', 'YourStrongPassword' );
define( 'DB_HOST', 'localhost' );On shared hosting the database host is normally localhost. If you install WordPress with the one-click installer, this file is filled in for you. See how to install WordPress.
Export a database with phpMyAdmin
- In cPanel, open phpMyAdmin from the Databases section.
- Select your database from the left sidebar.
- Click the Export tab, keep the Quick method and the SQL format, then click Export (or Go).
- A
.sqlfile will be downloaded to your computer. Keep it as a backup or use it to move your site.
Import a database with phpMyAdmin
- Create an empty database and user first (using the steps above).
- Open phpMyAdmin and select the empty database from the left sidebar.
- Click the Import tab, click Choose File and select your
.sqlfile (a compressed.sql.gzor.zipfile also works and uploads faster). - Click Import (or Go) at the bottom and wait for the success message.
For full-site backups, also see how to back up and restore your website.
Common problems
- "Error establishing a database connection" in WordPress: usually the database name, username or password in
wp-config.phpis wrong, the prefix is missing, or the user was not added to the database. Check all four values and the privileges. - "Access denied for user": the password is wrong or the user has no privileges on that database. Reset the password from MySQL® Databases and re-add the user with ALL PRIVILEGES.
- Import file is too large: phpMyAdmin shows the maximum upload size on the Import page. Compress the file with gzip, or contact support to import it for you.
- "Table already exists" during import: you are importing into a database that already has tables. Import into an empty database or drop the old tables first (after taking a backup).
Frequently asked questions
Why does my database name start with my cPanel username?
cPanel adds this prefix automatically so that database names stay unique on the server. Always use the full name, including the prefix, in your configuration files.
Can one user access more than one database?
Yes, you can add the same user to several databases, but for security it is better to use one user per website.
Can I connect to my database from my computer?
Remote connections are disabled by default. You can add your IP address in Remote Database Access in cPanel if your plan allows it, or contact support.
How do I change a database user's password?
Go to MySQL® Databases, find the user under Current Users, click Change Password, then update the new password in your website's configuration file.





