MySQL® Databases
outline
This interface allows you to create, manage, and delete MySQL® databases and database users.
The database name can contain up to 64 characters.
- Due to the way cPanel & WHM use to store MySQL database names, each underscore character requires 2 characters of that limit.
- If you enable database prefixes, database names can contain up to 63 characters , including the database prefix and the underscore character. Each additional underscore requires another 2 letters of that limit.
To add or delete information in an existing database, copy a database, or run MySQL queries and scripts, use cPanel's phpMyAdmin Use the interface ( cPanel > > Home > > Database > > phpMyAdmin ).
Caution :
create databases or users using phpMyAdmin . phpMyAdmin does not map databases , so backup and Restore doesn't work.
reference:
cPanel's MySQL Database Wizard interface ( cPanel > > We recommend that you use the Home > > Database > > MySQL Database Wizard ) to create database and user.
Create database
To create a database, follow these steps:
- Enter the database name in the New Database text box.
reference:
If your hosting provider has enabled database prefixes, a prefix based on your account username and an underscore character ( _ ) appear before the New Database text box. The system automatically prepends the prefix to the database name.
- Click Create Database . A new interface will appear.
- Click Go Back . The new database appears in the Current Databases ( Current Databases ) table.
To access and manage the database you created, use the phpMyAdmin interface ( cPanel > > Home > > Database > > phpMyAdmin ). For information on how to use phpMyAdmin, visit the phpMyAdmin website .
Remote MySQL host
note:
This section only appears if a remote MySQL configuration exists.
This section provides the address of the remote MySQL server configured by your hosting provider. You can use this host to connect to your MySQL server.
Database modification
If you experience problems with your database, check the database for errors.
Check database
To check the database for errors, follow these steps:
- From the Check Database menu, select the database you want to check.
- Click Check Database ( Check Database ). A new interface will appear and the system will check whether the database is functioning properly.
- When it detects a problem with the database, the system displays the names of the corrupted tables.
- If you see the Check Complete message, your database is working properly.
- Click Go Back to return to the main interface.
Database Recovery
If one of your databases is corrupted, you can attempt to recover it.
To recover a database, follow these steps:
- Select the database you want to repair from the Repair Database menu.
- Click Repair Database . A new interface will appear and the system will automatically attempt to repair the database.
- If the database cannot be repaired, the system attempts to determine the source of the corrupted data.
- When you see the Repair Complete message, the system has successfully repaired the database.
- Click Go Back to return to the main interface.
current database
Current Databases table lists the following information for each database in your account:
- database — database name
- Size — The size of the database.
- Privileged Users — Users who can operate the database.
note:
When modifying a database user, you must modify the user's access to the correct database. Users can access one or more databases.
- To remove a user from a database, click the trash can icon () for the desired user, and then click Revoke User Privileges from Database ( Revoke User Privileges from Database ).
- To modify a user's privileges for a specific database , select and uncheck the checkboxes for the desired username. Click to configure the permissions you want, then click Make Changes ( Make Changes ).
- Actions — Actions available for this database. Rename or delete a database by clicking the appropriate icon in this column.
Database Name Replace
WARNING :
- Renaming a MySQL database is potentially dangerous. Before renaming cPanel's Backup interface ( cPanel > > We strongly recommend that you perform a backup of your MySQL database from Home > > File > > Backup ).
- When you rename a database, the system terminates all active connections to the database.
- You must manually update your configuration files and applications to take advantage of the new database name.
- The system takes more time to rename larger and more complex databases.
To rename a database, follow these steps:
- In the Current Databases table, click Rename ( Rename ) for the desired database.
- In the New name ( New name ) text box, enter a new database name.
- Click Proceed ( Proceed ).
You cannot change the database name in MySQL. When cPanel & WHM “renames” a database, the system performs the following steps:
- The system creates a new database.
- The system moves data from the old database to the new database.
- The system regenerates the authorization and stored code in the new database.
- The system will delete the old database and its permissions.
caution:
- If any of the first three steps fail, the system returns an error and attempts to restore the original state of the database. If the restore process fails, the error response from the API function describes these additional failures.
- In rare cases, the system successfully creates the second database but fails to delete the old database or permissions. The system processes the rename operation as a success. However, the API function returns a warning stating that it cannot delete old databases or permissions.
Delete database
To delete a database, follow these steps:
- In the Current Databases table, click Delete for the desired database.
- To permanently delete a database, click Delete Database ( Delete Database ).
- Click Go Back to return to the main interface.
Add MySQL user
After creating the database, configure permissions by adding users to the database.
reference:
- You must create a MySQL user account separate from your mail and web administrator accounts.
- To add a user to an existing database, you must first create the user.
To create a new user account, follow these steps:
- Enter your username in the Username text box.
reference :
Database username restrictions
- MySQL
- MySQL limits database usernames to 16 characters. The system includes the database prefix (the first 8 characters of your cPanel account username plus the underscore character) in the number of characters in your username.
- Example: MySQL databases with the db_ prefix allow usernames containing up to 13 characters.
MySQL databases with the example_ prefix allow usernames of up to 8 characters.
- MariaDB
- MariaDB limits database usernames to 47 characters. The system includes the database prefix (the username and the underscore character for all cPanel accounts) in the number of characters in the username.
- Example: MariaDB database with db_ prefix allows username containing up to 44 characters.
MariaDB databases with the example_ prefix allow user names containing up to 39 characters.
- Enter the new password in the appropriate text box and confirm.
reference:
- The system evaluates the password you enter on a 100-point scale. 0 indicates a weak password and 100 indicates a very secure password.
- Some web hosts require a minimum password strength. A green password Strength meter indicates that the password is greater than the required password strength.
- To generate a strong password, click Password Generator . For more information, see our Password & Security Please read the article.
- Click Create User .
- Click Go Back to return to the main interface.
Add user to database
To add a user to the database, follow these steps:
- In the Add User To Database section of the interface, select the desired user and database from the menu.
- Click Add ( Add) . The MySQL Account Maintenance interface appears.
- Check the boxes corresponding to the permissions you want to grant to the user.
reference:
To grant a user all available privileges, select the ALL PRIVILEGES checkbox.
- Click Make Changes ( Make Changes ).
- Click Go Back to return to the main interface.
For more information about user permissions, read MySQL documentation .
current user
Current Users table lists all MySQL database users and allows you to:
- Change Password — Click to modify the database user's password. Enter and confirm your desired password, then click Change Password .
- Rename — Click to rename a database user. Enter your desired username, then click Change Username ( Change Username ).
- Delete — Click to permanently delete a database user, then click Delete User to continue.
View original text: MySQL® Databases