How to create a database on command line in MySQL?


First, you need to open the command prompt. You can open using shortcut windows+R key.

The screenshot is as follows −

Now type CMD and press OK button −

Now the following command prompt would be visible −

Now reach the MySQL bin directory. The screenshot is as follows −

Following is the query to run MySQL in the command line to create a database −

Now you can check the database is created or not using SHOW DATABASES command −

mysql> SHOW DATABASES;

This will produce the following output −

+---------------------------+
| Database                  |
+---------------------------+
| bothinnodbandmyisam       |
| business                  |
| commandline               |
| customer_tracker_database |
| customertracker           |
| database1                 |
| databasesample            |
| demo                      |
| education                 |
| hb_student_tracker        |
| hello                     |
| information_schema        |
| javadatabase2             |
| javasampledatabase        |
| login                     |
| mybusiness                |
| mydatabase                |
| mysql                     |
| onetomanyrelationship     |
| onlinebookstore           |
| performance_schema        |
| rdb                       |
| sample                    |
| sampledatabase            |
| schemasample              |
| sys                       |
| test                      |
| test3                     |
| tracker                   |
| universitydatabase        |
| web                       |
| webtracker                |
+---------------------------+
32 rows in set (0.00 sec)

Updated on: 30-Jul-2019

3K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements