How-tocPanel
How to create a MySQL database in cPanel
- Reading time
- 4 min
- Last updated
- 31 Oct 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.
-
01
Open the Database Wizard
In cPanel, go to Databases → Database Wizard (called MySQL Database Wizard in cPanel 118 and earlier). Servers running MariaDB show the same screens under the same name.
-
02
Name the database
Type a short name such as
shop. cPanel adds your account username as a prefix, so the real name becomes something likecpuser_shop. Write down the full name; your application needs it exactly. -
03
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.
-
04
Grant privileges
For a normal application, tick ALL PRIVILEGES. For a reporting or read-only user, tick only SELECT. Click Next Step.
-
05
Connect your application
Use
localhostas the database host, with the full prefixed database name, username and password. In WordPress these go inwp-config.phpasDB_NAME,DB_USER,DB_PASSWORDandDB_HOST.To load existing data, open phpMyAdmin, select the database and use Import with your
.sqlor.sql.gzfile. For a file larger than the upload limit, use the cPanel Terminal:mysql -u cpuser_shopuser -p cpuser_shop < dump.sql. Terminal needs shell access, which our cloud plans include.
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 Manage My Databases (MySQL Databases in cPanel 118 and earlier); 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
→Read next
→Hosting for this
Plans that fit what you just read.
A GST invoice on every plan, and free SSL and free managed migration on the cPanel plans (shared, WordPress, cloud and reseller). On VPS and VDS, migration is free with managed support.
→Get started
Hosting that does this for you.
Free SSL and managed migration on cPanel plans, and engineers on WhatsApp chat, 24/7, with a first reply in under 2 minutes.