Ask AI
English

How can you manage databases via the cPanel interface?

4 min read

Most dynamic websites, such as a WordPress site or an online shop, store their content – posts, products, users and settings – in a database. Managing databases in cPanel isn’t complicated, but if you’ve never done it before, or are used to a different control panel, it’s easy to get stuck at first.

In this article, we’ll walk you through the most common operations: creating a database, assigning users, checking and repairing it, renaming it and deleting it.

Creating a database using the MySQL Database Wizard

The easiest way is to use the MySQL Database Wizard, which you’ll find in the Databases section of cPanel. The wizard guides you through the process in four steps:

  1. Database name: enter the name. cPanel adds your account username and an underscore in front of it (for example, felhasznalo_wordpress), so you will need to enter this full name in the application.
  2. Database user: create a user and set a strong password for them. Use the password generator button to create a secure password; make a note of it, as you’ll need it later.
  3. Permissions: tick the ‘All Privileges’ option unless the application description specifies otherwise.
  4. Done: the database and the user have been set up and are now linked.

You will then need to enter the database name, username and password when installing the application (in the wp-config.php file for WordPress). The server name within the hosting environment is usually localhost. If you install WordPress using WP Toolkit, it will create the database automatically.

You can also find step-by-step instructions with images in the knowledge base article on creating MySQL databases in cPanel.

Video: cPanel Tutorials - How to Work With MySQL Databases (cPanelTV)

Adding a user to an existing database

If you want to assign a user to an existing database, open the MySQL Databases page:

  1. If you do not yet have a user account, please create one in the ‘Add New User’ section.
  2. In the ‘Add User To Database’ section, select the user and the database, then click the ‘Add’ button.
  3. Select the required permissions (usually all of them) and click the ‘Make Changes’ button.

You can also change a user’s password here; if you do, don’t forget to update it in the app’s settings as well.

Checking and repairing databases

If the site reports a database error, or a table appears to be corrupted, you can check the tables using the ‘Check Database’ function in the ‘Modify Databases’ section of the MySQL Databases page. If the system finds an error, you can try to repair it using the ‘Repair Database’ function.

You can also do this on a table-by-table basis within the phpMyAdmin interface: select the relevant tables and choose either ‘Check table’ or ‘Repair table’ from the drop-down menu. We’ve covered the basics of using phpMyAdmin in detail in our article on the fundamentals of phpMyAdmin.

If the automatic repair doesn’t help, the safest solution is to restore a previous backup. Daily backups are taken of cPanel hosting accounts, from which you can also restore your database in the Backup & Restore interface, even into a new database.

Renaming a database

On the MySQL Databases page, you can give a database a new name using the ‘Rename’ option next to it. This is a delicate operation: while the database is being renamed, any site using that database will not work, and afterwards you will need to update the database name in every application; otherwise, the site will display an ‘Error establishing a database connection’ message.

Important: always create a backup of your database before renaming, for example using the Export function in phpMyAdmin or via the Backup page in cPanel.

Deleting a database

You can remove unused databases on the MySQL Databases page by selecting the ‘Delete’ option next to the database in the ‘Current Databases’ list, then confirming with the confirmation button. A deleted database can only be restored from a backup, so before deleting it, please ensure that no website is using it. You can check which database an application is connected to in its configuration file (in WordPress, this is the wp-config.php file).

Deleting users is a separate step: after deleting the database, you can delete the associated user from the Current Users list.

Useful information

  • Every application should have its own database and its own user, so that if one site is hacked, it cannot access the data of the others.
  • The size of your databases counts towards your storage usage; it’s worth clearing out large, abandoned tables from time to time.
  • If you want to connect to the database from an external machine (for example, your own computer), you can do so through an encrypted SSH tunnel; the article on remote access to the cPanel database explains how.
Back to the blog