Databases

Create a MySQL database and user in cPanel

Create a MySQL database, a database user and the right privileges in cPanel with the Database Wizard or Manage My Databases, then connect your app with the correct details.

BeginnercPanel hosting2 min read

Most websites, from WordPress to custom PHP apps, store their content in a MySQL (MariaDB) database. In cPanel a working database needs three things: the database, a user, and that user added to the database with privileges. The Database Wizard does all three in one flow.

Before you start

  • Access to cPanel.
  • A name for the database, such as shop. cPanel adds your username as a prefix, so it becomes cpuser_shop.

Create a database with the Database Wizard

  1. Open cPanel → Databases → Database Wizard.
  2. Step 1: type the database name after the prefix and click Next Step.
  3. Step 2: enter a username (after the prefix, up to about 32 characters in total) and a strong password. Use Password Generator and copy the password somewhere safe. Click Create User.
  4. Step 3: tick ALL PRIVILEGES and click Next Step. Apps need these to create and update their tables.
  5. Step 4: cPanel confirms the user was added to the database.

Or use Manage My Databases

For more control, open cPanel → Databases → Manage My Databases (called MySQL Databases in older versions):

  1. Under Create New Database, enter the name and click Create Database.
  2. Under Database Users → Add New User, create the user.
  3. Under Add User To Database, pick the user and database, click Add, tick ALL PRIVILEGES and click Make Changes.

The same page lets you rename or delete databases, change user passwords, and run Check Database and Repair Database on damaged tables.

Connect your application

SettingValue
Database hostlocalhost
Database namecpuser_shop (with prefix)
Usernamecpuser_shopuser (with prefix)
PasswordThe password from step 2
Port3306 (default; most apps do not need it)

For WordPress these go in wp-config.php as DB_NAME, DB_USER, DB_PASSWORD and DB_HOST. If you install apps with Softaculous, it creates the database for you.

Note: Database size counts toward your disk quota. Check it on the Manage My Databases page.

Troubleshooting

"Access denied for user"

The password is wrong, the prefix is missing, or the user was never added to the database. Reset the password under Current Users → Change Password and re-check Privileged Users in the database list.

"Error establishing a database connection"

See fix database connection errors on cPanel.

Name too long

Shorten the part after the prefix. The full name and username have length limits.

Next steps

Was this guide helpful?

Still stuck?

Ask MdmHost AI for a quick answer, or open a ticket and our team will take a look. We are here 24/7.