How to Create a MySQL Database in cPanel

Many scripts, such as content management systems, shopping carts, require a database to operate.  When installing certain scripts, it may request that you create a database for the script.  You can create a database in the web hosting control panel.

Set up a New Database Using the Wizard

If you only need one database user, then the fastest way to create a new database is using the MySQL Database Wizard, as shown in this video. The wizard is simply a streamlined way to going through the necessary steps, which are outlined below.

Video Tutorial

Creating the Database and Authorized Users

To fully create and configure your database so it is ready to use, you will have to complete three steps. If you need multiple users, or simply want more control of the process, you can complete these steps one at a time.

Step 1: Create the Database

First you will need to create the database itself.

  1. Log into cPanel.
  2. Look for the Databases section, and click on the MySQL Databases icon.
  3. In the Create New Database section, enter the name you want to give the database. 
    • You will notice that your username will be prepended to your database name (foe example, if your username is example, and you enter “mydb”, then you database will be named “example_mydb” in the system.
  4. Click on the Create Database button.
  5. After it says your database is created, click on the Go Back link to continue.

Step 2: Create a Database User

For security reasons, you will create one or more database users with permissions to interact and modify the database.  Your script will use the database user’s credentials to interact with the data.

If you already have created a database user you want to use, you can skip to step 3.

  1. In the Add New User section, enter the username and password you want to create.
    • You can optionally use the Password Generator to create a secure password.
  2. Click on the Create User button.
  3. After it says your user is created, click on the Go Back link to continue.

Step 3: Give User Access to the Database

Now that you have created a database and a user, you have to give that user permission to access the database.

  1. Go to the Add User to Database section.
  2. Select a User from the list.
  3. Select a Database from the list.
  4. Click on the Add button.
  5. Select the necessary privileges for the user. 
    • If you want the script to have full access, click on the checkmark next to All Privileges.  Be aware this means the script can do anything, including create and delete everything in the database.
  6. Click on the Make Changes button.
  7. After it says your changes were saved, click on the Go Back link to continue.

You now have a database setup, and an authorized user to access that database.  Use this information (name of database, username and password) to setup any scripts or web applications that need to access the new database.

Recommended Content

2 Comments

forumpoll's picture

This is a very informative article.

Thanks for the article! This is a very detailed, and interesting article.

Forumpoll.xyz - Submit your forum, to get a free 24 hour Advertisement slot Automatically!