Page tree
Skip to end of metadata
Go to start of metadata

For cPanel & WHM version 56

(Home >> Databases >> MySQL Databases)


Warning:

This document describes functionality from cPanel's deprecated x3 theme. We strongly recommend that you use cPanel's current theme (Paper Lantern) instead.

  • We removed the deprecated x3 theme from new installations in cPanel & WHM version 60.
    • Make certain that you read the appropriate documentation for your version of cPanel & WHM.
    • For more information, read our What's My Version Number documentation.
  • cPanel's Paper Lantern theme does not include certain x3 theme-specific features.
    • For a complete list of Paper Lantern features, read our cPanel Features List documentation.
    • If you need a feature that the Paper Lantern theme does not include, submit a feature request.

Overview

Use this interface to create, manage, and delete MySQL® databases and database users.

Notes:

  • To create your first database and user, we recommend that you use the MySQL Database Wizard - x3 interface (Home >> Databases >> MySQL Database Wizard).
  • The maximum length of the database name is 64 characters. However, due to the method that cPanel & WHM uses to store MySQL database names, each underscore character requires two characters of that limit. Therefore, if you enable database prefixing, the maximum length of the database name is 63 characters, which includes the database prefix and the underscore character. Each additional underscore requires another two characters of that limit.
  • To enter information in an existing database, use the phpMyAdmin interface (Home >> Databases >> phpMyAdmin).

Important:

Do not use phpMyAdmin to create databases or database users.

Create a database

Remember:

We recommend that you use the MySQL Database Wizard - x3 interface (Home >> Databases >> MySQL Database Wizard) to create your first database and user.

To create a database, perform the following steps:

  1. In the New Database text box, enter a name for the database.

  2. Click Create Database.
  3. Click Go Back. The new database appears in the Current Databases table.

Modify Databases

Check a database

If you experience problems with a database on your server, check your databases for errors.

To check a database for errors, perform the following steps:

  1. In the Check a Database menu, select the database that you wish to check.

  2. Click Check the Database.
  3. cPanel runs a script that checks to ensure that 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.

Repair a database

If one of your databases is corrupt, you must repair it.

To repair a database, perform the following steps:

  1. In the Repair the Database menu, select the database that you wish to repair.
  2. Click Repair the Database.

cPanel runs a script that attempts to automatically repair the database.

Note:

This function only attempts to repair the database. The repair may not succeed. If it does not, the system attempts to help you locate the source of the corrupt data.

Current Databases

The Current Databases table lists the following information for each database in your account:

  • Database — The name of the database.
  • Size — The size of the database.
  • Privileged Users — The users who can manipulate the database.
  • Actions — Click the appropriate icon in this column to rename or delete a database.

Modify a user's privileges

To modify a user’s privileges for database management, perform the following steps:

  1. Click the username in the row that corresponds to the database for which you want to modify privileges. The MySQL Account Maintenance interface appears. 

    Note:

    Ensure that you select the correct database. Users may have access to more than one database.

  2. Select the checkboxes that correspond to the privileges that you want to grant to the user. Deselect any privileges that you do not wish to grant to the user.
  3. Click Make Changes.

For more information about user privileges, read the MySQL documentation.

Remove a user from a database

To remove a user from a specific database, perform the following steps:

  1. In the Privileged Users column, click the   icon next to the user that you want to delete.
  2. To remove the user from the database, click Revoke User Privileges.

Rename a database

Warning:

  • It is potentially dangerous to rename a MySQL database. We strongly recommend that you perform a backup of the MySQL database 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 the Rename icon () in the Actions column that corresponds to the database that you wish to delete.
  2. Enter the new database name in the New name text box.
  3. Click Proceed.

How cPanel renames a MySQL database

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:

  • 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 the Delete icon () in the Actions column that corresponds to the database that you wish to delete.
  2. To permanently delete the database, click Delete Database.

Add a MySQL user

After you create a database, add users to the database and configure their privileges.

Notes:

  • 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. 

    Important:

    To learn more about database username limits, click your database type to expand the following:

     MySQL

    MySQL limits the database username to 16 characters. The system includes the database prefix (the first eight characters of the cPanel account's username and an underscore character) in the character count for the username.

    For example:

    • A MySQL database with the db_ prefix allows usernames up to 13 characters long.
    • A MySQL database with the example_ prefix allows usernames up to eight characters long.
     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 up to 44 characters long.
    • A MariaDB database with the example_ prefix allows usernames up to 39 characters long.

  2. Enter and confirm the new password in the appropriate text boxes.

    Notes:

    • The system grades 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 password 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 Generator - x3 documentation.

  3. Click Create User.

Add a user to a database

To add a user to a database, perform the following steps:

  1. Select the appropriate user and the database you want to add the user to from the User and Database menus.
  2. Click Add. The MySQL Account Maintenance interface appears.
  3. Select the checkboxes that correspond to the privileges that you wish to grant to the user.

    Note:

    To grant all of the available privileges to the user, select the ALL PRIVILEGES checkbox.

  4. Click Make Changes.

For more information about user privileges, read the MySQL documentation.

Current Users

The Current Users table lists all of your MySQL users. Use the functions in this table to change user passwords and usernames, or to delete users.

Change MySQL user's password

To change a MySQL user's password, perform the following steps:

  1. In the Current Users table, click the Set Password icon () in the Actions column that corresponds to the user that you wish to change.
  2. Enter and confirm the new password in the appropriate text boxes.

    Notes:

    • The system grades 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 password 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 Generator - x3 documentation.

  3. Click Change Password.

Change a MySQL user's name

To change a MySQL user's username, perform the following steps:

  1. Click the Rename icon () in the Actions column for the user who you wish to rename.
  2. Enter the new username in the New Username text box. 

    Important:

    To learn more about database username limits, click your database type to expand the following:

     MySQL

    MySQL limits the database username to 16 characters. The system includes the database prefix (the first eight characters of the cPanel account's username and an underscore character) in the character count for the username.

    For example:

    • A MySQL database with the db_ prefix allows usernames up to 13 characters long.
    • A MySQL database with the example_ prefix allows usernames up to eight characters long.
     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 up to 44 characters long.
    • A MariaDB database with the example_ prefix allows usernames up to 39 characters long.

  3. Click Change Username.

Delete a MySQL user

To delete a MySQL user account, perform the following steps:

  1. Click the Delete icon () in the row that corresponds to the user that you wish to delete.
  2. To permanently delete the account, click Delete MySQL Users.