Skip to content
0850 554 5439 [email protected]

What do you need help with?

Search the guides and tutorials, or browse the categories.

How to create a MySQL database and user in cPanel: step by step with Database Wizard

Shared Hosting 29 views Step-by-step guide Last verified: Markdown
What you will learnHow to create a new database and user in four steps with Database Wizard in cPanel, give the user the right privileges and add the details to your site's configuration file. We also show how to manage the database in Manage My Databases.
Time5 minutes

1. When do I need to create a database by hand?

If you install software such as WordPress with Softaculous, the database is created for you and you don't need this guide (B31). You need to create one yourself when:

  • You install software by hand from its own files.
  • You are moving a site from another server and will import its database backup (B36).
  • You are adding an application to your site that needs its own database.

A site needs three details: the database name, the database user and that user's password. The wizard creates all three in one flow and connects the user to the database.

The tools are in the Databases section of the cPanel home page.

Database Wizard in the cPanel Databases section creates the database, the user and the privileges in one flow.

2. Step 1: Create the database

  1. Open Database Wizard in the Databases section.
  2. On Step 1: Create A Database, type a short name in New Database (for example gyroproje_db).
  3. The grey prefix to the left of the box (your cPanel username and an underscore) is added automatically; you don't type it. The full name looks like username_gyroproje_db.
  4. Click Next Step.
In step 1, type the database name; cPanel puts your account username in front of it.
Info

Use only lowercase letters, numbers and underscores. The total length including the prefix is limited; the "characters max" note on screen shows how many you have left.

3. Step 2: Create the database user

  1. On Step 2: Create Database Users, type a name in Username (for example gyroproje_us). The same prefix is added to it.
  2. Generate a strong password with Password Generator, or type your own of at least 16 characters.
  3. Enter the password again in Password (Again). The Strength bar should be green and high; cPanel won't create the user with a weak password.
  4. Save the password in a password manager; you will put it in the configuration file shortly.
  5. Click Create User.
In step 2, enter the database user name and a strong password; Password Generator can create one.
Warning

Don't reuse your cPanel password for the database. This password sits in your site's configuration file; keeping it separate means you only have to change that one if something goes wrong.

4. Step 3: Grant privileges

  1. On Step 3: Add user to the database, check the user and database names.
  2. For WordPress and similar software, tick ALL PRIVILEGES. This selects every privilege box below it.
  3. Click Next Step at the bottom of the page.
In step 3, tick ALL PRIVILEGES and click Next Step.
Info

If your software only reads data (for example a reporting tool), granting only SELECT is safer. Software that installs and updates itself (WordPress, WooCommerce) creates and changes tables, so it needs all privileges.

5. Step 4: Finish and add the details to your site

  1. On Step 4: Complete the Task you see a green message saying the user was added to the database.
  2. The links there let you add another database or user, or go back to Manage My Databases.
Step 4 confirms that the user was added to the database.
  1. Enter the details in your software's configuration file. In WordPress this is wp-config.php; open it with File Manager and edit these lines:
Line What to enter
DB_NAME The full database name with prefix (e.g. username_gyroproje_db)
DB_USER The full username with prefix (e.g. username_gyroproje_us)
DB_PASSWORD The password you created in step 2
DB_HOST localhost
  1. Save the file and open your site. If you see the installer or your site, the connection works.

6. Manage your databases

Manage My Databases in the Databases section lists all your databases.

  • The Current Databases table shows each database's Size and Privileged Users.
  • Check Database and Repair Database under Modify Databases check and repair damaged tables.
  • The Actions column has Rename and Delete.
  • Users are listed further down the page; you can change a user's password there. If you do, update the configuration file too.
Manage My Databases shows the database, its size and its privileged users.
Warning

Delete can't be undone; everything in the database is lost. Before deleting, take a backup with phpMyAdmin (B36) and check in wp-config.php which site uses the database. If you rename a database that is in use, you must update the configuration file as well.

Remote Database Access lets another computer connect to your database by allowing its IP address. If your site runs on the same hosting account, you don't need it; only allow a fixed IP address you really need.

7. Common problems

Symptom Cause Fix
"Error establishing a database connection" Wrong name, user or password in the configuration file Check the full prefixed names and the password; if needed, set a new password for the user in Manage My Databases and put it in the file.
"Access denied for user" The user isn't added to the database or lacks privileges In Manage My Databases, use Add User To Database and grant ALL PRIVILEGES.
The wizard rejects the password The password is too weak Use Password Generator or make the password longer.
"Already exists" warning A database or user with that name exists Choose another name or use the existing one.
The installer can't create tables Only limited privileges were granted Grant the user ALL PRIVILEGES.

8. FAQ

How many databases can I create?

It depends on your plan; the statistics panel on the cPanel home page shows how many you have used and how many remain. Current limits are in the plan comparison on our hosting page.

What is the database server address?

Your site runs on the same hosting account, so localhost is enough.

Can one user be connected to several databases?

Yes, but we recommend a separate user for each site. That way a problem on one site doesn't reach another site's database.

I forgot my database password. How do I find it?

Passwords aren't shown. On WordPress it is written in the DB_PASSWORD line of wp-config.php. If you can't find it, change the user's password in Manage My Databases and put the same password in the configuration file.

How do I move a database to another account?

Export it with phpMyAdmin and import it into an empty database you created on the new account (B36).

Did you know?

Software installed with Softaculous creates its database and user for you, with a random strong password. You only need a manual setup for software that isn't in Softaculous.

Next step

  • B36: Exporting and importing databases with phpMyAdmin
  • B31: Installing WordPress in cPanel
  • B32: Resetting your WordPress admin password
Was this helpful?

Thanks for your feedback!

Still Need Help?

The support team is here around the clock for anything you can't find in the knowledge base.