How to create Database and import SQL file to MySQL using Command Line

 

To create a blank database, launch the MySQL shell by entering:

mysql –u root –p

enter  password

mysql> CREATE DATABASE new_db_name;

Go to the created database use below command

mysql> USE new_db_name;

Display the contents of the database by typing:

mysql> SHOW TABLES;

Now you  can't see any tables because we haven't imported any table or database in it

Now below command simple import the .sql

mysql> source path/to/file.sql;

Now you can use show tables command to see imported tables

Comments

Popular posts from this blog

How can I debug PHP cURL sessions?

[PHP] Create MySQL Trigger in PHP

Free icons