Importing Mysql Database in Command Line in Windows
We are discussing different ways and methods to use Mysql DBMS effectively and efficiently. We have discussed how to install the Mysql DBMS to use in your projects. We have discussed how to create users and grant them privileges in command line. Now we are in a position to go further to create database in Mysql or import database mysql command line for windows.
Now as you are aware of how to use Mysql command line interface to create users and grant them privileges. Let us first import database mysql command line in windows and after that we will create database in mysql.
To import database mysql command line first you have to run the mysql command line interface. Now we are going to show you that database files are saved where we are on command line prompt now. So we are in the same directory where the database files which are to be imported are stored. Now to import the databases we type the following commands:
C:UsersemilyDesktopsql_databse_files>mysql -u username -p database_name < file.sql
Or with db_admin user name and password as password we have following statement:
C:UsersemilyDesktopsql_databse_files>mysql -u db_admin -p < file.sql
When you will type one of these statement depending upon your requirements you will be asked to enter a password. Then enter a password and the database is imported now.
Create Database in Mysql Command Line
To create a database in Mysql it is very easy to do. Run the command line interface for Mysql. Login to your account and just type the following statement:
mysql>CREATE DATABASE my_database;
After you press the enter key the database name my_databse will be created. Now you can see the database by typing the following statement:
How to delete a database in Mysql
To delete or drop a database in Mysql, type the following statement:
mysql>DROP DATABASE my_database;
It will drop the database my_database. Be very careful while dropping or deleting a database because it will not ask you for a confirmation to delete the database. We will discuss more about how to create tables and update and delete them, in later posts.