How to create new database in mysql

To create a new database in MySQL, you can use the following steps:

Method 1: Using the MySQL Command-Line Tool

  1. Open a terminal or command prompt and connect to your MySQL server using the following command:

    mysql -u your_username -p

    Replace your_username with your MySQL username and your_password with your MySQL password.

  2. Once connected, create a new database using the following command:

    CREATE DATABASE your_database_name;

    Replace your_database_name with the name you want to give your new database.

For example:

CREATE DATABASE my_new_database;
  1. Press Enter to execute the command. If the database is created successfully, you will see a message indicating that the database has been created.

Method 2: Using phpMyAdmin

  1. Open phpMyAdmin in your web browser by navigating to http://your_server_ip/phpmyadmin (replace your_server_ip with the IP address of your server).
  2. Log in to phpMyAdmin using your MySQL username and password.
  3. Click on the "Databases" tab.
  4. Click on the "Create database" button.
  5. Enter the name of your new database in the "Database name" field.
  6. Click on the "Create" button to create the database.

Method 3: Using a MySQL Client Tool

You can also use a MySQL client tool such as MySQL Workbench or HeidiSQL to create a new database.

  1. Open MySQL Workbench or HeidiSQL and connect to your MySQL server.
  2. Click on the "Database" tab.
  3. Click on the "Create database" button.
  4. Enter the name of your new database in the "Database name" field.
  5. Click on the "Create" button to create the database.

Regardless of the method you use, you can verify that the database has been created by running the following command:

SHOW DATABASES;

This will list all the databases on your MySQL server, including the new one you just created.