Different ways to import database using command line in MySQL ?
Below are the different ways to import database sql file using mysql command.
Import database using command line in MySQL : Method 1
Use the following command to import database using command line in MySQL :
C:\xampp-7\mysql\bin> mysql -u username -p password databaseName < location of the file where it is located.
** location of the file can be C:\testfolder\test.sql .
Import database using Mysql Console Screen: Method 2
Another way is :
first login to the mysql window screen and see the below screen.
mysql > Use databasename; mysql> source C:\testfolder\test.sql(location of the file you want to import);
As you press enter key, you will see processing like below. and it will import database successfully.
Import database using Mysql Console in Ubuntu/Linux:
Use the following way :
mysql> use databasename; Database changed. mysql> source /var/www/html/xyz.sql; //path to your database file Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.00 sec)
After successful completion use below command to see list of tables.
mysql> show tables;
Please let me know if you face any issues.