« Back

Setting Up MySQL Databases in cPanel

cPanel Webhosting

cPanel provides a user-friendly interface for creating and managing MySQL databases. Below is a step-by-step guide to help you get started.

In cPanel, database names are limited to a maximum of 55 characters. It’s important to note that each underscore (_) in the database name counts as two characters toward this limit due to the way cPanel stores MySQL database names. The underscore, commonly used to separate words or elements in names, was originally designed as a text underlining character. Additionally, cPanel enforces a rule that prevents creating new accounts with usernames that share the same first eight characters, ensuring unique identification across accounts.

To manage the data in your existing databases, duplicate a database, or run MySQL queries and scripts, you can use the phpMyAdmin tool in cPanel (cPanel > Home > Databases > phpMyAdmin).

Important! Avoid using phpMyAdmin to create new databases or users. It doesn’t correctly map databases, which can cause problems with backups and restores.

Tip: If you’re setting up your first database and user, the MySQL Database Wizard in cPanel (cPanel > Home > Databases > MySQL Database Wizard) is the easiest and most reliable way to get started. It guides you step-by-step through the process.

 

Creating a Database

To set up a new database, follow these steps:

1. Enter the desired name for your database in the New Database field.

2. Select Create Database to continue. This will open a new interface. Here, you need to provide a username and password for the database. It is recommended to use cPanel’s Password Generator to create a strong password for added security. If the password is not strong enough, your database—and ultimately your website—could be at risk of being compromised!

3. Select Go Back. The newly created database will now be listed in the Current Databases table.

Use the phpMyAdmin interface (cPanel > Home > Databases > phpMyAdmin) to access and manage the databases you create.

 

Checking a Database – Table Verification

To check a database for errors in phpMyAdmin, follow these steps:

1. Select the database.

2.Click the option to select all tables in the database. Then, from the drop-down menu for actions, choose the option to check the tables. A new interface will appear, and the system will verify whether the database is functioning correctly. If any issues are found, the name of the problematic table will be displayed.

3. Use your browser’s Back button or navigate back to the main database page in phpMyAdmin.

 

Repairing a Database – Table Repair

If a database is damaged, you can attempt to repair it by following these steps:

1.Select the database or table you want to repair from the list.

2.Use the drop-down menu to choose the option for repairing tables. A new interface will appear, and the system will attempt to perform an automatic repair. If the system cannot repair the database, it will try to identify the source of the issue.

3. Use your browser’s Back button to return to the main interface.

 

Renaming a Database

Renaming a MySQL database can be risky. Before proceeding, create a backup using cPanel’s Backup tool (cPanel > Home > Files > Backup) to prevent data loss.

Steps to rename a database:

  1. In the Current Databases section, click Rename next to the database.
  2. Enter the new name in the New name field.
  3. Click Proceed to save changes.

Since MySQL doesn’t support direct renaming, cPanel completes the following steps:

  1. Creates a new database with the specified name.
  2. Copies all data from the old database to the new one.
  3. Recreates grants and stored code for the new database.
  4. Deletes the original database and its grants.

Important!

  • Renaming will terminate all active connections to the database.
  • You’ll need to manually update configuration files and applications to reflect the new database name.
  • Larger databases may take longer to rename.

 

Deleting a Database

To remove a database, follow these steps:

  1. In the Current Databases table, locate the database you want to delete and click Delete.
  2. Confirm the deletion by clicking Delete Database to permanently remove it.
  3. Click Go Back to return to the main page.

 

Adding a User to a Database

To assign a user to a database, follow these steps:

  • In the Add User to Database section, choose the user and database from the drop-down menus.
  • Click Add to proceed.
  • In the MySQL Account Maintenance interface, select the privileges you want to grant to the user by checking the corresponding boxes.

Tip: To give the user full access, check the ALL PRIVILEGES box.

  • Click Make Changes to save the settings.
  • Click Go Back to return to the main page.

For detailed information about user privileges, refer to the MySQL documentation.

 

Current Users

The Current Users table shows all the MySQL database users and lets you:

  • Change Password
  • Rename
  • Delete

Looking for cPanel web hosting?

Rackhost has the perfect plan for you.

Learn more

Related posts