Databases

Manage MySQL databases and users in cPanel: create, rename, grant and delete

Use cPanel MySQL Databases to create databases and users, assign the right privileges, rename or delete databases safely, and fix common access denied errors.

BeginnercPanel hosting2 min read

Almost every dynamic website (WordPress, Joomla, Laravel, online shops) stores its content in a MySQL or MariaDB database. In cPanel a database and a database user are separate objects: you create both and then link them with privileges. This guide covers the full lifecycle in MySQL Databases. For a guided one-page setup use the MySQL Database Wizard instead.

Before you start

  • Access to cPanel.
  • Know that cPanel adds your account name as a prefix. If your cPanel user is mdmuser and you type shop, the real name is mdmuser_shop. Use the full name in your application.

Create a database

  1. Open cPanel → Databases → MySQL Databases.
  2. Under Create New Database, type a short name such as shop.
  3. Click Create Database, then Go Back.

Create a database user

  1. On the same page, scroll to MySQL Users → Add New User.
  2. Enter a Username (it also gets the prefix).
  3. Enter a strong password or use the Password Generator, and copy it somewhere safe.
  4. Click Create User.

Add the user to the database and grant privileges

  1. Under Add User To Database, select the user and the database, then click Add.
  2. On the Manage User Privileges page, tick ALL PRIVILEGES for a normal web application, or tick only the ones you need (for example SELECT for a read-only reporting user).
  3. Click Make Changes.

Your application now connects with host localhost, the full database name, the full username and the password.

Tip: Use one user per application. If one site is compromised, the attacker cannot read your other databases.

Change privileges or a user password

  • In Current Databases, click the username under Privileged Users to edit its privileges.
  • In Current Users, click Change Password next to the user. Update the password in your application's config file (for WordPress, wp-config.php) straight away.

Rename a database

  1. In Current Databases, click Rename next to the database.
  2. Enter the new name and click Proceed.
  3. Update the database name in your application's configuration.

Warning: Renaming copies the data into a new database and drops the old one. On large databases it can take time and the site will show database errors until the config is updated. Take a backup first.

Delete a database or user

  1. Export a backup first with phpMyAdmin or cPanel → Files → Backup.
  2. In Current Databases, click Delete next to the database and confirm. This cannot be undone from cPanel.
  3. Remove unused users in Current Users with Delete.

Troubleshooting

  • Access denied for user: the user is not added to the database, or the password in your config is wrong. Re-add the user with ALL PRIVILEGES and reset the password.
  • Unknown database: you used the short name; include the account prefix.
  • Connecting from your own computer: allow your IP in Remote MySQL.

Next steps

Was this guide helpful?

Still stuck?

Ask MdmHost AI for a quick answer, or open a ticket and our team will take a look. We are here 24/7.