A website can look finished on the front end and still need one critical piece behind the scenes: a database. WordPress, ecommerce platforms, contact forms, membership tools, and many custom applications use MySQL to store content, settings, customer details, and more. Knowing how to create a MySQL database and user in cPanel gives you more control when installing software, moving a site, or troubleshooting a database connection.
The process is straightforward in cPanel, but there is one step people often miss: creating the user is not enough. You must also assign that user to the database and give it the proper privileges. Follow the steps below and keep your database details in a secure place.
Before You Create a MySQL Database in cPanel
Start by signing in to your hosting account and opening cPanel. Look for MySQL Databases in the Databases section. Some hosting plans may show a limit on the number of databases or database users available, so it is worth checking that you have room before you begin.
You will need four details when connecting an application to the database: the database name, database username, password, and database host. On most shared hosting accounts, the database host is localhost. If your application requires a different value, check its setup instructions or contact support before changing anything.
cPanel usually adds your account username as a prefix to database and user names. For example, if your cPanel username is cpaneluser and you name a database store, the full database name may become cpaneluser_store. Use the full name shown in cPanel when entering credentials in WordPress or another application.
How to Create a MySQL Database and User in cPanel
1. Create the database
In cPanel, open MySQL Databases. At the top of the page, find the Create New Database section. Enter a short, descriptive name, such as wordpress, shop, or clientportal, then select Create Database.
Choose a name that makes sense later. A site with several tools can quickly accumulate databases, and a clear label helps prevent accidental changes to the wrong one. Once cPanel confirms the database was created, select Go Back to return to the MySQL Databases page.
Creating the database gives your website a place to store information, but no application can use it yet. Next, you need to create a separate database user.
2. Create a database user
Scroll to the MySQL Users section and find Add New User. Enter a username and create a strong password. You can use cPanel’s Password Generator to create a long, random password that is much harder to guess than a familiar word or reused login.
Save the password in a secure password manager. You may need it during a WordPress installation, a site migration, or future troubleshooting. If you lose it, you can reset the password later, but you must also update the password anywhere your website uses that database connection.
Select Create User when you are ready. Like database names, usernames commonly include your cPanel account prefix. This is normal and helps keep accounts separated on shared hosting servers.
3. Add the user to the database
This is the step that makes the new user able to access the new database. On the same MySQL Databases page, find Add User To Database. Select the database you created, select the new user, and click Add.
cPanel will then display a privileges screen. For a typical WordPress, Joomla, Drupal, or other web application installation, select ALL PRIVILEGES. This allows the application to create tables, read and write data, update settings, and perform normal maintenance.
Then select Make Changes. You should see a confirmation that the user has been added to the database with the selected privileges.
For a custom application, the right permissions can depend on what the software needs to do. A reporting tool that only reads data may only need SELECT permission, while a full website platform usually needs broader access. When you are unsure, follow the application’s documentation rather than guessing. Restricting permissions can improve security, but overly limited permissions can cause installation failures or errors when the site tries to update content.
4. Record the complete database credentials
Before leaving cPanel, record the following information exactly as displayed:
- Database name
- Database username
- Database password
- Database host, usually
localhost
These values are case-sensitive in many applications. A missing account prefix, an extra space, or an incorrect password can produce a database connection error even when the database itself was created correctly.
Connect Your Website to the Database
The next step depends on the software you are installing. With a one-click installer, the installer may create the database automatically or ask you to select an existing one. If you are installing WordPress manually, you will enter the database details during the setup screen.
For an existing WordPress site, these settings are stored in the wp-config.php file. Other applications may store database credentials in a configuration file, an environment file, or a setup panel. Do not edit configuration files unless you are certain which database the site should use. A typo in the database name or password can take the site offline until it is corrected.
If you are moving a website from another host, creating a new database and user is only part of the migration. You must also import the old database backup into the new database and update the website configuration with the new credentials. The database name alone does not move your site data.
Test the Connection Safely
After entering the credentials in your application, visit the site or complete the installation. A successful page load is often the simplest confirmation that the database connection is working.
You can also view the database in phpMyAdmin, available in cPanel. phpMyAdmin lets you see tables, import backups, and export copies of a database. It is useful for verifying that an import worked, but use care when editing or deleting tables. Changes there can affect your live website immediately.
If your site reports an error establishing a database connection, check the database name, username, password, and host first. Confirm that the user is assigned to the correct database and has the necessary privileges. If the credentials appear correct, reset the database user’s password and update it in the application configuration. This resolves many setup issues caused by copied or outdated credentials.
Keep Database Access Secure
A database user should be treated like any other sensitive login. Do not use your cPanel password as the database password, and do not send credentials through unprotected messages. Create a separate user for each application when practical, especially if different websites or developers need access.
Backups matter, too. A website backup that does not include its database may not restore posts, products, form submissions, or user accounts. Before major updates, migrations, or design changes, make sure you have a current backup of both your website files and its MySQL database.
When a database is no longer used, remove the user first and then remove the database only after confirming that no active site depends on it. A little organization now makes future maintenance much easier.
Creating a database in cPanel takes only a few minutes, and it gives your website a dependable foundation for the work happening behind every page. Keep the credentials organized, use a strong password, and let expert hosting support help if a connection issue does not have an obvious fix.