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
- Log in to your cPanel account.
- In the Databases section, click MySQL Databases.
- Under Create New Database, enter a name (e.g.,
myapp_db). - Click Create Database.
- Your hosting will add a prefix automatically (e.g.,
username_myapp_db). This is normal.
Step 2: Create a Database User
- Scroll down to MySQL Users → Add New User.
- Enter a username (e.g.,
myapp_user). - Enter a strong password (or use the password generator).
- Click Create User.
- The username will also be prefixed (e.g.,
username_myapp_user). - Save the password — you will need it when configuring your application.
Step 3: Link the User to the Database
- Scroll down to Add User to Database.
- Select the user and the database you just created from the dropdowns.
- Click Add.
- On the privileges screen, check ALL PRIVILEGES to give the user full access.
- 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
localhosthost 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
localhostas 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.