How to create a MySQL database and user in cPanel: step by step with Database Wizard
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.
2. Step 1: Create the database
- Open Database Wizard in the Databases section.
- On Step 1: Create A Database, type a short name in New Database (for example
gyroproje_db). - 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. - Click Next Step.
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
- On Step 2: Create Database Users, type a name in Username (for example
gyroproje_us). The same prefix is added to it. - Generate a strong password with Password Generator, or type your own of at least 16 characters.
- 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.
- Save the password in a password manager; you will put it in the configuration file shortly.
- Click Create User.
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
- On Step 3: Add user to the database, check the user and database names.
- For WordPress and similar software, tick ALL PRIVILEGES. This selects every privilege box below it.
- Click Next Step at the bottom of the page.
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
- On Step 4: Complete the Task you see a green message saying the user was added to the database.
- The links there let you add another database or user, or go back to Manage My Databases.
- 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 |
- 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.
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).
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
Thanks for your feedback!
