Valid for cPanel & WHM versions 106 through the latest.

Last modified: June 9, 2025


Overview of MySQL® Databases in cPanel & WHM

This interface serves as your central hub for managing MySQL® databases and database users within your cPanel account. Here, you can effortlessly create new databases, manage existing ones, and remove those no longer needed, alongside controlling user access.

When naming your databases, it's important to be aware of the character limits and how special characters are handled:

  • A database name can contain a maximum of 64 characters.
  • Each underscore character (_) utilized in a database name counts as two characters against this limit due to cPanel & WHM's internal storage methods.
  • If database prefixing is enabled on your server, a database name is limited to a maximum of 63 characters. This limit includes the automatically added database prefix and the underscore character that separates it from your chosen name. Any additional underscores within your custom name will also count as two characters each.

Note: To optimize database naming and manage character limits more effectively, your hosting provider can use the Force short prefix for MySQL and MariaDB databases setting. This option is found in WHM’s Tweak Settings interface (WHM » Home » Server Configuration » Tweak Settings). Enabling this setting restricts the database prefix to a maximum of eight characters. For comprehensive details on MySQL and MariaDB® prefix configurations, please refer to our dedicated Tweak Settings documentation.

Warning: Be aware that enabling the Force short prefix for MySQL and MariaDB databases setting in WHM’s Tweak Settings interface (WHM » Home » Server Configuration » Tweak Settings) will prevent the creation of new cPanel accounts whose usernames share the same first eight characters. This is a crucial consideration for server administrators.

For more advanced database operations, such as adding or deleting information within existing databases, copying databases, or executing complex MySQL queries and scripts, you should utilize cPanel’s dedicated phpMyAdmin interface (cPanel » Home » Databases » phpMyAdmin). This tool provides a powerful graphical interface for interacting directly with your database content.

Warning: It is strongly advised against using phpMyAdmin to create new databases or database users. Databases created via phpMyAdmin do not correctly map databases within the cPanel & WHM system, which can lead to critical issues with backup and restoration processes. Always use the cPanel MySQL Databases interface or the MySQL Database Wizard for database and user creation.

Note: For users creating their very first database and user, we highly recommend using cPanel’s MySQL Database Wizard interface (cPanel » Home » Databases » MySQL Database Wizard). This wizard streamlines the initial setup process, guiding you through creating a database and assigning a user with appropriate privileges.

Creating a New Database

To establish a new MySQL database within your cPanel account, follow these straightforward steps:

  1. In the New Database text box, carefully enter the desired name for your new database. Choose a name that is descriptive and easy to identify.

    Note: If your hosting provider has configured database prefixing, you will notice a pre-filled prefix appearing before the New Database text box. This prefix is typically based on your account username followed by an underscore character (_). The system will automatically prepend this prefix to the database name you enter, ensuring unique identification across the server.

  2. Click the Create Database button. The system will process your request, and a confirmation interface will appear shortly.
  3. After confirmation, click Go Back to return to the main MySQL Databases interface. Your newly created database will now be visible and listed within the Current Databases table, ready for use.

Once your database is created, you can utilize the phpMyAdmin interface (cPanel » Home » Databases » phpMyAdmin) to access and manage its contents. For detailed instructions on how to effectively use phpMyAdmin, please refer to the comprehensive documentation available on the phpMyAdmin website.

Remote MySQL Host Configuration

Note: This section will only be displayed within your cPanel interface if a remote MySQL configuration has been established and enabled by your hosting provider. If you do not see this section, it means remote access is not currently configured for your account.

This segment of the interface displays the network address of the remote MySQL server that your hosting provider has configured for your account. This host address is crucial as it allows you to connect to the MySQL server from external applications or tools, enabling remote database management and integration with other services.

Managing and Modifying Existing Databases

Maintaining the health and integrity of your databases is vital. The following sections describe how to check for and repair issues within your MySQL databases.

Checking a Database for Errors

If you suspect that a database is experiencing problems or wish to verify its integrity, you can perform a check for errors:

  1. From the Check Database dropdown menu, select the specific database you wish to examine for errors.
  2. Click the Check Database button. A new interface will load, and the system will proceed to thoroughly examine the selected database for any inconsistencies or corruption.
    • Should the system detect an issue, it will clearly display the name of the corrupt table(s) within the database.
    • If the message Check Complete is displayed, it signifies that the database is functioning correctly and no errors were found.
  3. Click Go Back to return to the main MySQL Databases interface and continue with other tasks.

Repairing a Corrupt Database

In unfortunate instances where one of your databases becomes corrupt, cPanel provides a built-in tool to attempt an automatic repair:

  1. From the Repair Database dropdown menu, select the database that you need to repair.
  2. Click the Repair Database button. A new interface will appear, and the system will initiate an automatic attempt to rectify any corruption within the database.
    • If the system is unable to fully repair the database, it will provide information attempting to determine the underlying source of the corrupt data, which can be helpful for further manual troubleshooting.
    • If the message Repair Complete is displayed, it indicates that the system has successfully repaired the database, restoring its functionality.
  3. Click Go Back to return to the primary interface once the repair process is finished.

Understanding Current Databases

The Current Databases table provides a comprehensive overview of all MySQL databases associated with your cPanel account. This table displays key information for each database and offers various management actions:

  • Database — This column lists the full name of your database, which also corresponds to the DB_HOST value used for connecting to the database.
  • Size — This indicates the current size of the database on the server, measured in megabytes or gigabytes.
  • Privileged Users — This section lists all users who currently have access and permissions to manipulate the specific database. These names also serve as the DB_USERNAME values for database connections.

    Note: When adjusting database user privileges, always ensure that you are modifying access for the correct database. A single user may have access to multiple databases, so precision is key.

    • To revoke a user's access from a particular database, locate the desired user in this column and click the associated trash can icon (trash can icon). Then, confirm your action by clicking Revoke User Privileges from Database.
    • To modify a user’s specific privileges for a given database, click on the username. A new interface will allow you to select or deselect checkboxes to configure the exact permissions (e.g., SELECT, INSERT, UPDATE, DELETE) the user should have. After making your selections, click Make Changes to apply.
  • Actions — This column provides quick access to available actions for each database. You can click the appropriate icon to either rename the database or delete it entirely.

Renaming a Database

Warning: Renaming a MySQL database is an operation that carries potential risks. We strongly advise that you perform a full backup of your MySQL database using cPanel’s Backup interface (cPanel » Home » Files » Backup) immediately before attempting to rename it. This precaution will safeguard your data in case any issues arise during the renaming process.

Furthermore, please be aware of the following implications when renaming a database:

  • All active connections to the database will be terminated during the renaming procedure.
  • You will be required to manually update any configuration files, scripts, or applications that referenced the old database name to reflect the new name.
  • Renaming larger or more complex databases may take a significant amount of time to complete.

To rename an existing database, follow these steps:

  1. In the Current Databases table, locate the desired database and click the Rename action icon associated with it.
  2. Enter the completely new database name into the New name text box.
  3. Click Proceed to initiate the renaming operation.

It's important to understand that MySQL itself does not natively support renaming a database directly. When you "rename" a database through cPanel & WHM, the system internally executes a series of complex operations:

  1. The system first creates an entirely new database with the name you specified.
  2. All data from the old database is then meticulously moved and migrated to the newly created database.
  3. Grants and any stored procedures or functions associated with the old database are meticulously recreated within the new database.
  4. Finally, the original database and its associated grants are permanently deleted from the system.

Warning: During this intricate process, certain failure scenarios can occur:

  • If any of the initial three steps (creating the new database, moving data, or recreating grants/stored code) fail, the system will return an error message and attempt to revert the database to its original state. Should the restoration process itself fail, the API function's error response will provide details on these additional failures.
  • In rare circumstances, the system may successfully create the second database but encounter issues when attempting to delete the old database or its grants. In such cases, the rename action will still be considered a success by the system; however, the API function will issue warnings detailing the failure to delete the old database or grants.

Deleting a Database

To permanently remove a database from your cPanel account, follow these steps:

  1. In the Current Databases table, locate the database you wish to delete and click the Delete action icon next to it.
  2. A confirmation prompt will appear. To permanently delete the database and all its associated data, click Delete Database. Please note that this action is irreversible.
  3. After the deletion is complete, click Go Back to return to the main interface.

Adding a MySQL User

After you have successfully created a database, the next crucial step is to add users to that database and configure their specific privileges, controlling what actions they can perform.

Note: It is essential to remember that MySQL user accounts are distinct and must be created separately from your cPanel mail or web administrator accounts. Furthermore, a user account must be created before it can be assigned to an existing database.

To create a new MySQL user account, follow these steps:

  1. Enter a unique username for the new database user in the Username text box. Be mindful of character limits, which vary depending on your MySQL/MariaDB version:

    MySQL 5.6 and Earlier

    For MySQL 5.6 and older versions, the database username is limited to a maximum of 16 characters. This character count actively includes the database prefix, which typically consists of the first eight characters of the cPanel account's username followed by an underscore, totaling nine characters for the prefix.

    For example:

    • If your cPanel account's prefix is db_, you can use up to 13 characters for the custom part of the username (16 - 3 = 13).
    • If your cPanel account's prefix is example_, you can use up to 8 characters for the custom part of the username (16 - 8 = 8).

    MySQL 5.7 and Later

    MySQL 5.7 and subsequent versions offer an increased username limit of 32 characters. Similar to earlier versions, this limit includes the database prefix, which for these versions comprises the first sixteen characters of the cPanel account’s username plus an underscore, totaling seventeen characters for the prefix.

    For example:

    • With a db_ prefix, usernames can contain up to 29 characters (32 - 3 = 29).
    • With an example_ prefix, usernames can contain up to 24 characters (32 - 8 = 24).

    MariaDB

    MariaDB provides the most generous username limit, allowing up to 47 characters. For MariaDB databases, the system includes the full cPanel account’s username and an underscore character as the database prefix.

    For example:

    • If your MariaDB prefix is db_, usernames can contain up to 44 characters (47 - 3 = 44).
    • If your MariaDB prefix is example_, usernames can contain up to 39 characters (47 - 8 = 39).
  2. Enter your desired password in the first password text box, and then re-enter it in the confirmation text box to ensure accuracy.

    Note:

    • This password directly corresponds to the user’s DB_PASSWORD value required for database connections. For security reasons, cPanel & WHM does not reveal this value after creation. If you forget it, you will need to change the user’s password.
    • The system assesses the strength of the password you enter on a scale from 0 to 100 points, where 0 signifies a very weak password and 100 represents an exceptionally secure password.
    • Some web hosting providers enforce a minimum password strength policy. A green Strength meter visually indicates that your chosen password meets or exceeds the required security threshold.
    • To generate a highly secure and complex password automatically, click the Password Generator button. For further guidance on creating robust passwords and enhancing account security, consult our comprehensive Password & Security documentation.
  3. Click Create User to finalize the creation of the new MySQL user account.
  4. Click Go Back to return to the main MySQL Databases interface.

Assigning a User to a Database

After creating both a database and a user, you need to grant that user specific permissions to interact with the database. Follow these steps to assign a user to a database and configure their privileges:

  1. In the Add User To Database section of the interface, use the respective dropdown menus to select the desired user account and the target database.
  2. Click the Add button. This action will redirect you to the MySQL Account Maintenance interface, where you can define the user's permissions.
  3. On the MySQL Account Maintenance interface, select the checkboxes that correspond to the specific privileges you wish to grant to the user (e.g., SELECT, INSERT, UPDATE, DELETE, CREATE, DROP).

    Note: To assign all available privileges to the user, simply select the ALL PRIVILEGES checkbox. This grants full control over the selected database.

  4. Click Make Changes to apply the selected privileges to the user for that database.
  5. Click Go Back to return to the main MySQL Databases interface.

For more in-depth information regarding MySQL user privileges and their implications, we recommend consulting the official MySQL documentation.

Managing Current Users

The Current Users table provides a convenient way to manage all MySQL database users associated with your cPanel account. From this table, you can perform several important actions:

  • Change Password — To modify a database user’s password, click the Change Password link next to their username. You will then be prompted to enter and confirm the new desired password. After entering, click Change Password to update it. This is useful if a password is forgotten or needs to be strengthened.
  • Rename — To rename an existing database user, click the Rename link. Enter the desired new username in the provided field, and then click Change Username. This allows for better organization and adherence to naming conventions.
  • Delete — To permanently remove a database user from the system, click the Delete link. A confirmation prompt will appear; click Delete User to proceed with the permanent deletion. Be cautious, as this action cannot be undone and will remove the user's ability to access any databases they were previously assigned to.
War diese Antwort hilfreich? 0 Benutzer fanden dies hilfreich (0 Stimmen)