How to Create a Database and User for WordPress in cPanel Step by Step

A WordPress site needs a database to store posts, pages, settings, and user accounts. If you are installing WordPress manually, moving a site, or fixing a database connection error, you may need to create a MySQL database, create a database user, and assign privileges in cPanel.

This guide walks through those steps carefully, then shows how to connect the database to WordPress using wp-config.php. It also covers quick outage checks, credential troubleshooting, and safe rollback steps. cPanel layouts differ between hosting providers, so button names may vary slightly.

Before You Start: Fast, Reversible Checks

If the site is currently down, start with checks that do not change files or database settings. A database error can be caused by a typo, a temporary hosting problem, or a broader server issue. Avoid changing several settings at once; that makes it harder to identify the cause.

  • Record the exact message and time. Note the full error text, the page or action that triggers it, and the time, including your time zone. For example: Error establishing a database connection at 10:42 a.m. Pacific time. This scratchpad can help match the issue to hosting logs.
  • Check whether the outage is site-wide. Try the homepage and a known page in a private browser window. If you have access, compare the site with another site on the same hosting account.
  • Check the hosting provider’s service-status page. Look for reported MySQL, web-server, or control-panel incidents. A server-side outage cannot be fixed by repeatedly changing WordPress credentials.
  • Do not delete or recreate a database during triage. If this is an existing site, first confirm which database contains its content and make a backup before making changes.

If the site is working and you are setting up a new WordPress installation, continue with the setup steps below. If it is an existing site, check the current database details in wp-config.php before creating anything new.

What You Need to Know About cPanel Databases

In cPanel, a WordPress database usually has three parts: a database name, a database user, and privileges that let the user perform necessary actions on that database. Your hosting provider may automatically add an account prefix to both the database and username. For example, you might enter store_wp but see the full name displayed as account_store_wp.

Item Purpose Where WordPress uses it Database name Identifies the database that stores site data DB_NAME in wp-config.php Database username Identifies the account WordPress uses to connect DB_USER in wp-config.php Database password Authenticates the database user DB_PASSWORD in wp-config.php Database host Specifies where the database server is reachable DB_HOST in wp-config.php

Step 1: Sign In to cPanel and Open the Database Tools

  • Sign in to your hosting account and open cPanel. Use the provider’s official sign-in route rather than a link from an unexpected email.
  • Find the Databases section. Depending on your cPanel version, you may see MySQL® Databases, MySQL Database Wizard, or both.
  • If available, use MySQL Database Wizard for a guided setup. The standard MySQL Databases page also works and may give you more control over each step.

Before changing an existing site, download a current backup through your hosting backup tool or a trusted backup process. Keep a copy somewhere outside the hosting account. Do not rely on a backup that has not been checked for completion.

Step 2: Create a MySQL Database

In the wizard, choose the option to create a database. In the standard interface, look for Create New Database.

  • Enter a short, descriptive database name, such as wp_site or client_blog.
  • Check the full name shown by cPanel, including any account prefix. Copy it exactly; the prefix is part of the database name WordPress must use.
  • Select Create Database and wait for cPanel to confirm that it was created.
  • Save the full database name in your setup notes. Do not put database credentials in a public document, support forum, or screenshot.

What changed: A new, empty database was created in the hosting account. How to roll back: If this is a brand-new, unused database, you can remove it later from MySQL Databases after confirming that it contains no needed data. Never remove a database associated with a live site without a verified backup and a clear recovery plan.

Step 3: Create a Database User

Next, create the database user that WordPress will use. In the wizard, choose the option to create a user. On the standard MySQL Databases page, use MySQL Users or Add New User.

  • Choose a unique username. cPanel may prepend your account name, so note the complete username displayed after creation.
  • Generate a strong, unique password. Use the cPanel password generator or a reputable password manager. Do not reuse your cPanel, email, or WordPress administrator password.
  • Save the password securely because it will be needed for wp-config.php. Do not send it in an unprotected email or chat message.
  • Select Create User and confirm that cPanel reports success.

What changed: A database login was created, but it may not yet have access to the database. How to roll back: You can remove the new user from the MySQL Users section if it is unused. Before removing a user from an existing installation, confirm that no other application depends on it.

Step 4: Add the User to the Database and Assign Privileges

Creating a database and user does not automatically connect them in every cPanel workflow. You must add user to database and assign privileges so WordPress can use the account.

  • In the wizard, select the database user and database you just created. In the standard interface, find Add User to Database.
  • Choose the full database name and full username, including any cPanel prefixes.
  • Select Add or Next Step.
  • On the privileges screen, select ALL PRIVILEGES for a typical WordPress installation, then save the changes. WordPress needs permission to create and update tables and manage its stored data.
  • Confirm cPanel displays a success message. If you do not see a privileges screen, return to MySQL Databases and check the current users assigned to that database.

Use a database user dedicated to this WordPress site when possible. Avoid granting access to unrelated databases, and do not give a user access to more than it needs. For standard WordPress operation, the full set of privileges on its own database is commonly used.

What changed: The chosen user was linked to the chosen database and granted the selected permissions. How to roll back: Use the database management page to revoke or adjust the user’s privileges. If you are reversing a mistaken assignment, verify the database and username before removing access so you do not interrupt another site.

Step 5: Add the Database Details to WordPress

WordPress reads its database connection settings from the wp-config.php file in the site’s main WordPress directory. For a new manual installation, you may find wp-config-sample.php instead; WordPress can also guide you through creating the configuration during installation.

Before editing an existing file, download a copy of wp-config.php and note its current modified time. Then open it using cPanel File Manager or your hosting provider’s file editor. Avoid increase PHP memory limit pasting credentials into a public ticket or leaving them in an unsecured local file.

Find the database settings, which look similar to this:

define( 'DB_NAME', 'account_wp_site' ); define( 'DB_USER', 'account_wp_user' ); define( 'DB_PASSWORD', 'your-unique-password' ); define( 'DB_HOST', 'localhost' );

Replace the example values with the exact details from cPanel:

  • DB_NAME: the full database name, including the account prefix.
  • DB_USER: the full database username, including the account prefix.
  • DB_PASSWORD: the password for that database user, entered exactly.
  • DB_HOST: the database host specified by your hosting provider. It is often localhost, but not always. Do not assume this value if your provider supplies a different hostname.

Keep the quotation marks and PHP syntax intact. Be careful with special characters in passwords: copy and paste from your password manager, then check that the quotes and semicolon around the setting have not been altered. Save https://instaquoteapp.com/what-does-adjourned-mean-in-brisbane-magistrates-court/ the file and test the site.

What changed: WordPress was pointed to the selected database using the chosen user’s credentials. How to roll back: Restore the backup copy of wp-config.php. If the old settings were already broken, restore only after checking whether the previous database remains available.

Rapid Troubleshooting: Database and Hosting Checks

“Error establishing a database connection”

Start by checking the values in wp-config.php against cPanel character by character. Confirm the full prefixed database name and username, password, and database host. Then confirm that the user is assigned to the correct database and has the required privileges.

“Access denied for user”

This often points to an incorrect username or password, or a user that lacks privileges. In cPanel, check the full username and its database assignment. If you reset the password, update DB_PASSWORD immediately to match. Do not change the password in one place and leave the other value unchanged.

“Unknown database”

Check for a missing account prefix, a spelling difference, or a database that was created under a different hosting account. Confirm the exact database name in cPanel before changing WordPress configuration.

The settings look correct, but the site is still down

Check hosting and server health before making more edits. Review the provider’s service status, available account notices, and any hosting tools that show MySQL service availability. If your plan includes error logs, note any relevant entry and its timestamp. A database server outage, account resource limit, or hosting-side configuration issue may require investigation by the provider.

When requesting assistance, send a concise report rather than a vague message. Include the domain, exact error text, timestamp and time zone, when the issue began, what changed most recently, and whether the database name, username, or password was recently edited. Do not include the database password or full contents of wp-config.php.

Final Verification Checklist

  • The database exists in cPanel and the full name is recorded.
  • The database user exists, and its full prefixed username is recorded securely.
  • The user has been added to the correct database and the intended privileges are active.
  • The DB_NAME, DB_USER, DB_PASSWORD, and DB_HOST values match the hosting account’s details.
  • The site loads, and you can view a page that reads content from the database.
  • A backup is available before any further changes.

Creating a database is only part of the setup: WordPress also needs the correct user, correctly assigned privileges, and matching values in wp-config.php. Work through those pieces in order, record exact errors and timestamps, and use reversible checks first. That approach makes a new installation more reliable—and helps you avoid turning a small configuration mistake into a longer outage.

Public Last updated: 2026-10-15 07:27:45 AM