Many applications (WordPress, Joomla, custom scripts) need a MySQL database to store their data. This guide shows you how to create a database, create a database user, and link them together in cPanel.

Step 1: Create the Database

  1. Log in to your cPanel account.
  2. In the Databases section, click MySQL Databases.
  3. Under Create New Database, enter a name (e.g., myapp_db).
  4. Click Create Database.
  5. Your hosting will add a prefix automatically (e.g., username_myapp_db). This is normal.

Step 2: Create a Database User

  1. Scroll down to MySQL Users → Add New User.
  2. Enter a username (e.g., myapp_user).
  3. Enter a strong password (or use the password generator).
  4. Click Create User.
  5. The username will also be prefixed (e.g., username_myapp_user).
  6. Save the password — you will need it when configuring your application.

Step 3: Link the User to the Database

  1. Scroll down to Add User to Database.
  2. Select the user and the database you just created from the dropdowns.
  3. Click Add.
  4. On the privileges screen, check ALL PRIVILEGES to give the user full access.
  5. Click Make Changes.

Step 4: Use the Database in Your Application

When configuring your application (e.g., WordPress), use these details:

  • Database Name: username_myapp_db (with prefix)
  • Database User: username_myapp_user (with prefix)
  • Database Password: the password you created in Step 2
  • Database Host: localhost

Important Notes

  • Database names and usernames must be unique on the server — that is why cPanel adds your username as a prefix.
  • Most hosting plans have a limit on the number of databases you can create. Check your plan details.
  • The localhost host works for most setups. If your hosting uses a remote database server, contact support for the correct host value.
  • You can manage your databases via phpMyAdmin (also in the Databases section of cPanel).
  • Delete unused databases to free up server resources.

Troubleshooting

  • "Database name already exists": A database with that name was already created. Check the "Current Databases" section and either use the existing one or choose a different name.
  • "User already exists": Same as above — check the "Current Users" section.
  • Application cannot connect to the database: Double-check that you are using the full database name and username (with prefix), the correct password, and localhost as the host. A single character error will cause connection failure.
  • "Access denied for user" error: The user is not linked to the database, or does not have the correct privileges. Go back to Step 3 and ensure the user is added to the database with ALL PRIVILEGES.
  • Forgot the database password: You cannot view existing passwords in cPanel. Delete the user and create a new one with a new password, then update the password in your application's configuration file.

Need help? Contact our support team.

Was this answer helpful? 0 Users Found This Useful (0 Votes)