Every application that uses a database (WordPress, Joomla, custom PHP apps) needs a database user with the right permissions. This guide covers how to create databases, create users, and assign users to databases in cPanel. It also covers common issues like forgotten passwords, permission errors, and the cPanel username prefix system.
cPanel Prefixes Everything
cPanel automatically adds your account username as a prefix to all database names and user names. If your cPanel username is myaccount and you create a database called wpdb, the actual name will be myaccount_wpdb. Use the prefixed name in your application's configuration file.
- ✓ Database name:
myaccount_wpdb(not justwpdb) - ✓ Username:
myaccount_dbuser(not justdbuser) - ✓ Host:
localhost(for apps on the same server) - ✓ Port:
3306(default, usually not needed in config)
01. Create a Database
- Log into cPanel - go to your hosting control panel
- Click "MySQL Databases" - in the Databases section
- Enter a name - under "Create New Database," type a name (e.g.,
wpdb). cPanel will add your username prefix automatically - Click "Create Database"
The database is now created but empty and has no users assigned to it. A database without a user is inaccessible to applications.
02. Create a Database User
- On the same MySQL Databases page - scroll down to "MySQL Users"
- Enter a username - (e.g.,
dbuser). Again, cPanel adds the prefix - Enter a password - use the Password Generator for a strong random password. Copy it somewhere safe; you'll need it for your application's config file
- Click "Create User"
The user is created but has no access to any database yet. You must complete Step 3 (Assign User to Database) or your application will show "Access denied" errors.
03. Assign User to Database
- Scroll to "Add User to Database" - still on the MySQL Databases page
- Select the user - from the User dropdown
- Select the database - from the Database dropdown
- Click "Add"
- Set privileges - check "ALL PRIVILEGES" for most applications, or select specific privileges if you need restricted access (see Section 4)
- Click "Make Changes"
The user now has access to the database. Your application's config file needs three values:
# WordPress example (wp-config.php):
define('DB_NAME', 'myaccount_wpdb');
define('DB_USER', 'myaccount_dbuser');
define('DB_PASSWORD', 'the_password_you_set');
define('DB_HOST', 'localhost');
04. Understanding Privileges
For most applications (WordPress, Joomla, Drupal, custom apps), grant ALL PRIVILEGES. This lets the application create tables, insert/update/delete data, and manage the schema as needed.
If you need to restrict a user (e.g., for a read-only reporting connection), here's what the key privileges do:
- SELECT - read data
- INSERT - add new rows
- UPDATE - modify existing rows
- DELETE - remove rows
- CREATE - create new tables
- DROP - delete tables (careful with this one)
- ALTER - modify table structure (columns, indexes)
- INDEX - create and delete indexes
WordPress needs at minimum: SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER, INDEX, and DROP. But it's simpler and safer (for updates and migrations) to just grant ALL PRIVILEGES unless you have a specific security reason not to.
05. Change a Database User Password
- Go to MySQL Databases in cPanel
- Scroll to "Current Users" - find the user you want to change
- Click "Change Password"
- Enter the new password and click "Change Password"
- Update your application config - change the password in wp-config.php (WordPress), configuration.php (Joomla), or wherever your application stores database credentials
Changing the database password in cPanel does NOT update your application's config file. If you change the password without updating the config, your site will show "Error establishing a database connection" until you update the password in the config file to match.
06. Using phpMyAdmin
phpMyAdmin is a web-based tool for directly managing database contents. Access it from cPanel > Databases > phpMyAdmin.
Common Tasks
- Browse data - click a database, then a table, to see its contents
- Run SQL queries - click the SQL tab to run custom queries
- Import data - click Import to upload a .sql file (useful for restoring backups or migrating)
- Export data - click Export to download a .sql dump (useful for backups)
- Search and replace - click the Search tab on a table to find specific values. Useful for finding hardcoded URLs after a domain or SSL change
- Optimize tables - select all tables, choose "Optimize table" from the dropdown. Reclaims disk space and can improve performance
For connection details and remote access, see our MySQL Port and Connection Guide.
07. Troubleshooting
"Error Establishing a Database Connection"
The most common database error. Check these in order:
- Database name - must include the cPanel prefix (e.g.,
myaccount_wpdbnotwpdb) - Username - must also include the prefix
- Password - must match exactly what's set in cPanel MySQL Databases
- User assigned to database - the user must be added to the database (Step 3 above)
- DB_HOST - should be
localhostfor apps on the same server
"Access Denied for User"
The user exists but doesn't have permission to access the specific database. Go to MySQL Databases, scroll to "Add User to Database," and add the user to the correct database with ALL PRIVILEGES.
"Unknown Database"
The database name in your config doesn't match any database in your account. Check the exact name (with prefix) in cPanel > MySQL Databases. Database names are case-sensitive on Linux.
"Too Many Connections"
Your application has too many simultaneous database connections open. This is usually caused by missing persistent connection settings or a traffic spike. If it happens consistently, you may need to optimize your application's database connection handling or consider a VPS or dedicated server with higher connection limits.
Need Help With Databases?
If you're having trouble setting up or connecting to a database, open a support ticket with the exact error message and which application you're configuring.
Open a Support TicketQuick Recap: MySQL Database Setup
If you only do 5 things from this guide, do these:
- Create the database - cPanel > MySQL Databases > Create New Database
- Create a user - with a strong generated password
- Add the user to the database - with ALL PRIVILEGES
- Use the prefixed names -
youraccount_dbnamein your config file - Set DB_HOST to localhost - for applications on the same server
Last updated March 2026 · Browse all Database articles
