How to Create a MySQL Database in CLI and cPanel

MySQL is a popular database management system that is widely used in web development. In this tutorial, we will guide you through the steps to create a MySQL database in both the CLI and cPanel.

Creating a MySQL Database in CLI:

Step 1: Open Command Line Interface

Open the command line interface (CLI) on your computer. On Windows, you can open the Command Prompt or PowerShell. On macOS or Linux, you can open the Terminal.

Step 2: Log in to MySQL

To create a database, you need to log in to MySQL. Type the following command in the CLI:

mysql -u root -p

This command will prompt you to enter the root password for MySQL.

Step 3: Create a Database

Once you are logged in, you can create a new database by typing the following command:


Replace “dbname” with the name you want to give your database. Press Enter to execute the command.

Step 4: Verify the Database

To verify that the database has been created, type the following command:


This command will display a list of all the databases on your MySQL server, including the one you just created.

Creating a MySQL Database in cPanel:

Step 1: Log in to cPanel

Log in to cPanel with your username and password.

Step 2: Open MySQL Databases

In the cPanel dashboard, navigate to the “Databases” section and click on “MySQL Databases.”

Step 3: Create a Database

Under “Create a New Database,” enter the name you want to give your database and click on “Create Database.”

Step 4: Create a Database User

Once your database has been created, you need to create a user who can access it. Scroll down to the “MySQL Users” section and enter a username and password. Click on “Create User.”

Step 5: Add User to Database

After creating the user, scroll down to the “Add User to Database” section. Select the user you just created and the database you want to give them access to. Click on “Add.”

Step 6: Set User Privileges

On the next screen, you can set the privileges that the user has on the database. You can select “All Privileges” to give the user full control over the database or choose specific privileges as needed. Click on “Make Changes” to save your settings.

In conclusion, creating a MySQL database is a simple process that can be done in both the CLI and cPanel. By following these simple steps, you can create a new database and start using it for your web development projects.