1. Knowledge Base
  2. >
  3. Results
  4. >
  5. How to Create or Delete a MySQL Database or User

How to Create or Delete a MySQL Database or User

 

Databases offer a method for managing large amounts of information over the web easily. They are necessary to run many web-based applications such as bulletin boards, content management systems, and online retail shops.

Note: Resellers can create accounts with usernames up to 16 characters long. Please note that MySQL Databases and Usernames will only include the first 8 characters. For example:
  • cPanel username: lengthyusername
  • MySQL Database: lengthyu_wrdp1
  • MySQL Username: lengthyu_johndoe

Jump to a Section

This video will show you how effortless it is to create the database and the database user and assign that user to your new database. This is standard practice for anyone looking to manually install third party programs that make use of MySQL databases.

Disclaimer: You may have a newer version of cPanel but the steps should be relatively the same.


Create or Delete a MySQL Database

Create a MySQL Database
  1. Log into cPanel.
  2. Under Databases, click MySQL Databases.
  3. In the New Database field, type a name for the database.
  4. Click Create Database.
  5. Click Go Back.
    • The new database will appear in the Current Databases table.
Delete a MySQL Database
  1. Navigate to the Current Databases section of MySQL Databases.
  2. In the Actions column of the table, click Delete next to the database you wish to delete.

    Current Databases

  3. Confirm that you wish to permanently remove the database.

    Database Delete Confirmation

If you would like to remove a user that has been assigned to a database, click the X next to the user on this table. Please see the instructions below ⤵ on how to assign a database user.

Create or Delete a Database User

After creating the database, you will need to create a user and assign privileges. Please note that MySQL user accounts must be created separately from mail and web administrator accounts.

Create a Database User
  1. Log into cPanel.
  2. Under Databases, click MySQL Databases.
  3. Click Jump to MySQL Users in the top-left corner of the page.
  4. Under Add New User, enter a username.

    MySQL Users Add New User

  5. Enter a password in the Password field.
    • For help generating a strong password, click the Generate Password button.
  6. Retype the password in the Password (Again) field.
  7. Click Create User.
Delete a Database User
  1. Navigate to the Current Users section of MySQL Databases.
  2. In the Delete column, click the Delete next to the user you wish to delete.

    Delete Current Users

Define a User's Privileges

Privileges determine how a user is able to interact with the database. For example, privileges will dictate whether or not the user can add and delete information.
 

Assign Privileges to Database User
  1. Log into cPanel.
  2. Under Databases, click MySQL Databases.
  3. Under Add User to Database, select a user from the User drop-down menu.
  4. From the Database drop-down menu, select the database to which you wish to allow the user access.

    Add User To Database

  5. Click Add.
  6. From the MySQL Account Maintenance screen, select the privileges you wish to grant the user or select ALL PRIVILEGES.

    Add User TO Database

  7. Click Make Changes.
Unassign a User from a Database
  1. Navigate to the Current Databases section of MySQL Databases.
  2. Locate the database you wish to modify.
  3. In the Privileged Users column for that database, click the X next to the user you wish to delete.

    Priveleged Users

Using the Database

Now that you can create databases and users and assign appropriate privileges, you can use the following articles as a reference to editing and connecting to your databases:

Delete a Database without Using cPanel

The steps below are done using SSH. If you know how to use it, follow these steps; however, if you need help, contact us via phone or Live Chat for assistance.

  1. Make a backup of the database with SSH using the command line below. Use your cPanel password.
    username@domain [~] # mysqldump --password username_database > username_database.db
    Enter password:  (cPanel Password)
    username@domain [~] #
    
  2. Next, use the DROP DATABASE command, inside of mysql, to delete the database.
    
    mysql> SHOW DATABASES LIKE "username_database";
    +------------------------------+
    | Database (username_database) |
    +------------------------------+
    | username_database            |
    +------------------------------+
    1 row in set (0.02 sec)
    
    mysql> DROP DATABASE username_database;
    Query OK, 0 rows affected (0.00 sec)
    
    mysql> SHOW DATABASES LIKE "username_database";
    Empty set (0.02 sec)
    
    mysql>
      

Go to DROP DATABASE Statement link for further information on this command.