title: MySQL® Databases created at: Sat Oct 19 2024 15:06:15 GMT+0000 (Coordinated Universal Time) updated at: Sat Feb 08 2025 14:21:42 GMT+0000 (Coordinated Universal Time) --- # MySQL® Databases # Overview Use this interface to create, manage, and delete MySQL databases and database users. > \[!NOTE] > Note > In cPanel & WHM version 120 and later, we renamed this interface to [*Manage My Databases*](https://docs.cpanel.net/cpanel/databases/manage-my-databases/) . A database name may contain a maximum of 64 characters. * Due to the method that cPanel & WHM uses to store MySQL database names, each underscore character requires **two** characters of that limit. * If you enable database prefixing, a database name may contain a maximum of **63 characters**, which includes the database prefix and the underscore character. Each additional underscore requires another **two** characters of that limit. > \[!NOTE] > Note > Use the *Force short prefix for MySQL and MariaDB databases* settings in WHM’s [*Tweak Settings*](https://docs.cpanel.net/whm/server-configuration/tweak-settings) interface (*WHM* » *Home* » *Server Configuration* » *Tweak Settings*) to limit the database prefix to eight characters. For more information about MySQL and MariaDB prefix settings, read our [Tweak Settings](https://docs.cpanel.net/whm/server-configuration/tweak-settings/#sql) documentation. > \[!WARNING] > Warning > Enabling the *Force short prefix for MySQL and MariaDB databases* setting in WHM’s [*Tweak Settings*](https://docs.cpanel.net/whm/server-configuration/tweak-settings) interface (*WHM* » *Home* » *Server Configuration* » *Tweak Settings*) will prevent you from creating new accounts that share the same first eight characters of their usernames. To add or delete information in existing databases, copy a database, or run MySQL queries and scripts, use cPanel’s [*phpMyAdmin*](https://docs.cpanel.net/cpanel/databases/phpmyadmin/) interface (*cPanel » Home » Databases » phpMyAdmin*). > \[!WARNING] > Warning > **Don’t** use phpMyAdmin to create databases or database users. phpMyAdmin **doesn’t** [map databases](https://docs.cpanel.net/whm/sql-services/database-map-tool) , which causes backups and restorations to not function. > \[!NOTE] > Note > We recommend that you use cPanel’s [*MySQL Database Wizard*](https://docs.cpanel.net/cpanel/databases/database-wizard) interface (*cPanel » Home » Databases » MySQL Database Wizard*) to create your **first** database and user. # Create a database To create a database, perform the following steps: 1. In the *New Database* text box, enter a name for the database. > \[!NOTE] > Note: If your hosting provider has enabled database prefixing, a prefix based on your account username and underscore character ( `_` ) will precede the *New Database* text box. The system automatically prepends this prefix to the database name. 1. Click *Create Database*. A new interface will appear. 2. Click *Go Back*. The new database appears in the *Current Databases* table. To access and manage databases that you create, use the [*phpMyAdmin*](https://docs.cpanel.net/cpanel/databases/phpmyadmin/) interface (*cPanel » Home » Databases » phpMyAdmin*). For information about how to use phpMyAdmin, visit the [phpMyAdmin website](http://www.phpmyadmin.net/home_page/docs.php) . # Remote MySQL Host > \[!NOTE] > Note > This section **only** appears if a remote MySQL configuration exists. This section provides the remote MySQL server’s address configured by your hosting provider. You can use this host to connect to the MySQL server. # Modify Databases If you experience problems with a database, check your databases for errors. ## Check a database To check a database for errors, perform the following steps: 1. In the *Check Database* menu, select the database that you wish to check. 2. Click *Check Database*. A new interface will appear, and the system will check whether the database functions correctly. * If the system detects a problem in the database, it displays the name of the corrupt table. * If the *Check Complete* message displays, the database functions correctly. 3. Click *Go Back* to return to the main interface. # Repair a database If one of your databases becomes corrupt, you can attempt to repair it. To repair a database, perform the following steps: 1. In the *Repair Database* menu, select the database that you wish to repair. 2. Click *Repair Database*. A new interface will appear, and the system will attempt to automatically repair the database. * If the system cannot repair the database, it will attempt to determine the source of the corrupt data. * If the *Repair Complete* message displays, the system successfully repaired the database. 3. Click *Go Back* to return to the main interface. # Current Databases The *Current Databases* table lists the following information for each database in your account: * *Database* — The name of the database. This is also the `DB_HOST` value. * *Size* — The size of the database. * *Privileged Users* — The users who can manipulate the database. These names are also `DB_USERNAME` values. > \[!NOTE] > Note\ > When you modify database users, make **certain** that you modify the user’s access to the correct database. Users may have access to more than one database. ``` - To remove a user from a database, click the trash can icon. ``` ![media\_MySQL%C2%AE%20Databases/HXUjBrJM9KL38i-trash.png](media_MySQL%C2%AE%20Databases/HXUjBrJM9KL38i-trash.png) ``` ) for the desired user, and then click _Revoke User Privileges from the Database_. - To modify a user’s [privileges for a specific database](http://dev.mysql.com/doc/) , click the desired username, select and deselect checkboxes to configure the desired privileges, and then click _Make Changes_. ``` * *Actions* — The available actions for this database. Click the appropriate icon in this column to rename or delete a database. ## Rename a database > \[!WARNING] > Warning > It is potentially dangerous to rename a MySQL database. We **strongly** recommend that you perform a backup of the MySQL database in cPanel’s [Backup](https://docs.cpanel.net/cpanel/files/backup-for-cpanel) interface (*cPanel » Home » Files » Backup*) before you attempt to rename it. > When you rename a database, the system terminates all active connections to the database. > You **must** manually update configuration files and applications to use the new database name. > The system requires more time to rename larger and more complex databases. To rename a database, perform the following steps: 1. In the *Current Databases* table, click *Rename* for the desired database. 2. Enter the new database name in the *New name* text box. 3. Click *Proceed*. MySQL does **not** allow you to rename a database. When cPanel & WHM “renames” a database, the system performs the following steps: 1. The system creates a new database. 2. The system moves data from the old database to the new database. 3. The system recreates grants and stored code in the new database. 4. The system deletes the old database and its grants. > \[!WARNING] > Warning > If **any** of the first three steps fail, the system returns an error and attempts to restore the database’s original state. If the restoration process fails, the API function’s error response describes these additional failures. > In rare cases, the system creates the second database successfully, but fails to delete the old database or grants. The system treats the rename action as a success; however, the API function returns warnings that describe the failure to delete the old database or grants. ## Delete a database To delete a database, perform the following steps: 1. In the *Current Databases* table, click *Delete* for the desired database. 2. To permanently delete the database, click *Delete Database*. 3. Click *Go Back* to return to the main interface. # Add a MySQL user After you create a database, add users to the database and configure their privileges. > \[!NOTE] > Note > You **must** create MySQL user accounts separately from mail and web administrator accounts. > You **must** create a user before you can add the user to an existing database. To create a new user account, perform the following steps: 1. Enter a username in the *Username* text box. To learn more about database username limits, click your database type: > \[!NOTE] > **MySQL 5.6 and earlier** > MySQL 5.6 limits the database username to 16 characters. The system includes the database prefix (the first eight characters of the cPanel account’s username plus an underscore for a total of nine characters) in the character count for the username. > For example: > A MySQL database with the `db_` prefix allows usernames that contain up to 13 characters. > A MySQL database with the `example_` prefix allows usernames that contain up to eight characters. > \[!NOTE] > **MySQL 5.7 and later** > MySQL 5.7 limits the database username to 32 characters. The system includes the database prefix (the first sixteen characters of the cPanel account’s username plus an underscore for a total of seventeen characters) in the character count for the username. > For example: > A MySQL database with the `db_` prefix allows usernames that contain up to 29 characters. > A MySQL database with the `example_` prefix allows usernames that contain up to 24 characters. > \[!NOTE] > **MariaDB** > MariaDB limits the database username to 47 characters. The system includes the database prefix (all of the cPanel account’s username and an underscore character) in the character count for the username. > For example: > A MariaDB database with the `db_` prefix allows usernames that contain up to 44 characters. > A MariaDB database with the `example_` prefix allows usernames that contain up to 39 characters. 1. Enter and confirm the new password in the appropriate text boxes. > \[!NOTE] > Note > This value corresponds to the user’s `DB_PASSWORD` value. However, cPanel & WHM does **not** reveal this value. If you forget the value, you must [change the user’s password](https://docs.cpanel.net/cpanel/databases/mysql-databases/#current-users) . > The system evaluates the password that you enter on a scale of 100 points. `0` Indicates a weak password, while `100` indicates a very secure password. > Some web hosts require a minimum password strength. A green *Strength* meter indicates that the password is equal to or greater than the required password strength. > Click *Password Generator* to generate a strong password. For more information, read our [*Password & Security*](https://docs.cpanel.net/cpanel/preferences/password-and-security) documentation. 1. Click *Create User*. 2. Click *Go Back* to return to the main interface. # Add a user to a database To add a user to a database, perform the following steps: 1. In the *Add User To Database* section of the interface, select the desired user and database from the menus. 2. Click *Add*. The *MySQL Account Maintenance* interface will appear. 3. Select the checkboxes that correspond to the privileges that you wish to grant to the user. > \[!NOTE] > Note\ > To grant all of the available privileges to the user, select the *ALL PRIVILEGES* checkbox. 1. Click *Make Changes*. 2. Click *Go Back* to return to the main interface. For more information about user privileges, read the [MySQL documentation](http://dev.mysql.com/doc/) . # Current Users The *Current Users* table lists all of your MySQL database users, and allows you to perform the following actions: * *Change Password* — Click to modify a database user’s password. Enter and confirm the desired password, and then click *Change Password*. * *Rename* — Click to rename a database user. Enter the desired username, and then click *Change Username*. * *Delete* — Click to permanently delete a database user, and then click *Delete User* to continue.