How to create a MySQL database in cPanel

Create a database, a database user and the link between them with cPanel’s Database Wizard, then find the exact values your website’s configuration needs.

2–4 minutes

Most websites, including WordPress, store their content in a MySQL or MariaDB database. In cPanelcPanel The most popular hosting control panel: a website where you manage your email, files, databases and domains with point-and-click tools instead of commands. More about cPanel →, a working database needs three things: the database, a user, and permission for that user on that database. The Database Wizard does all three in order.

Open Databases » Database Wizard. Name the database, create a user with a generated password, tick ALL PRIVILEGES, and finish. Your site then connects with the full names cPanel shows, which start with your cPanel username, such as exampleco_crm, and host localhost.

Step 1: Create the database

cPanel Database Wizard step 1 with the New Database field and Next Step button highlighted
Databases » Database Wizard, step 1.
  1. Type a short name, such as crm or blog. cPanel adds your username and an underscore in front, so the real name becomes exampleco_crm.
  2. Click Next Step.

Use lowercase letters and numbers. The full name has a length limit, shown under the field.

Step 2: Create the database user

cPanel Database Wizard step 2 with the username field, Password Generator button and Create User button highlighted
Step 2. The database was created; now the user.
  1. Username: again, cPanel adds your prefix, giving exampleco_crmuser.
  2. Click Password Generator, tick I have copied this password in a safe place, then Use Password. A generated password is safest, and you only need it once, for your site’s configuration file.
  3. Click Create User.

Create a separate user for each website or application. If one site is compromised, its password then opens only its own database.

Step 3: Give the user access

cPanel Database Wizard step 3 with the ALL PRIVILEGES checkbox and Next Step button highlighted
Step 3. ALL PRIVILEGES ticks every box below it.
  1. Tick ALL PRIVILEGES. Web applications such as WordPress need to create and change tables, especially during updates.
  2. Click Next Step.

Step 4: Done

cPanel Database Wizard step 4 confirming the user was added to the database
Step 4 confirms the user was added to the database.

The values your site needs

Your website’s configuration asks for four values. In WordPress they are in wp-config.php:

define( 'DB_NAME', 'exampleco_crm' );
define( 'DB_USER', 'exampleco_crmuser' );
define( 'DB_PASSWORD', 'the-generated-password' );
define( 'DB_HOST', 'localhost' );

Use the full names including the prefix. DB_HOST is localhost on almost every cPanel server, because the database runs on the same machine. If your host gives a different value, use theirs.

Managing databases later

Databases » Manage My Databases lists every database and user:

cPanel Manage My Databases page showing the Current Databases table and the Database Users section highlighted
Manage My Databases. Current Databases shows each database’s size and which users can use it.
  1. Current Databases shows size and privileged users, with Rename and Delete.
  2. Current Users lists users; change a password or delete a user here.

Further down, Add User To Database links an existing user to another database. Check Database and Repair Database fix damaged tables, which is the first thing to try when a site reports a crashed table. Take a backup first.

phpMyAdmin

Databases » phpMyAdmin opens a browser-based tool for looking inside databases: browse tables, run SQL queries, and import or export. It logs you in automatically. Use Export for a quick SQL copy of one database, and Import to load a .sql file into an empty database. For large imports, which time out in a browser, ask your host or use SSHSSH A secure way to type commands on a server from your own computer, as if you were sitting at it. More about SSH →.

Common errors

MessageCause
Error establishing a database connectionWrong name, user or password in the site’s configuration, or the user was never added to the database
Access denied for userThe password is wrong, or the user lacks privileges on that database
Unknown databaseThe name is missing its exampleco_ prefix
You are using X of X available databasesYour plan’s database limit is reached; delete unused ones or upgrade

Official documentation

Something out of date? Software changes. If a step no longer works, tell us and we will check it and update the page.