How To Create a Database Using CMD In MySQL Localhost
How to create a database using cmd in MySQL Localhost is a simple guide to create database in command line prompt. You can follow these steps to create database in Linux or mac using Linux shell or command line utility based on operating system. If you are using windows install WAMP server, xampp server or else you can install those individually. After installing follow this procedure.
Steps to create a database using cmd in MySQL Localhost
- Login to MySQL Database using command line prompt or shell .
- Next create MySQL Database in command line utility.
- Use the Database for creating tables.
1. Login to MySQL Database using command line prompt or shell
- If you are using WAMP, Open MySQL Console from System Tray icon.
- Or else open Command line utility or Shell, and use below command.
mysql -u your-database-username -p your-database-password
- your-database-username : this is the user name of your database
- your-database-password : this is the password of your database
- After connecting to database, you can proceed with next step.
2. Create MySQL Database
- For creating database form command line prompt or shell, Use the below command.
CREATE DATABASE nameofyourdatabase;
- CREATE DATABASE is the command, and next one is your database name.
- And at the end of statement semicolon is must.
3. Use the Database for creating tables
After creating the database, next step is creating table.
- For creating table, first you need to access the table or in common words you need to select the database.
- For selecting database command is
- Then you can continue with creating tables in that database.
If you want to view all the databases, then use this simple command to list all the databases. SHOW DATABASES; This command will lists all the databases.
how to create database by using cmd