Import sql command windows: Yesterday I need to import database dump sql file to import in my sql database using command line in widows. We can import database dump direct in phpmyadmin import functionality but is the file is very big then we need to import using command line. I have try more then time but nothing got success to import sql file in mysql command line windows.
In my previous article we already explain importing sql file to dadtabase in ubuntu. But here we want to tell you How do I import an SQL file using the command line in MySQL?. So, let’s start to import sql file to database using command line in windows.
First you need to got the xamp>bin section where your xamp mysql
Now run bellow command, Here you need to ad your database Name and the sql file path where it is stable. In our view its downloads file.
mysql -u root -p database_name < "C:\Users\Anil\Downloads\sql_file.sql"
Look like how the command run from and the path section below the full command line.
C:\xampp\mysql\bin>mysql -u root -p openhouz < "C:\Users\Trilok\Downloads\openhouz.sql"
After running the this command in terminal you need to add your database password in command and then the process is running automatically. If you don’t add any password in database then you can enter without typing in password section.
Many times if the file is bigger then we consumes MySQL Error 1153 – Got a packet bigger than ‘max_allowed_packet’ bytes same like errors then we need to some changes in before running the command.
Then you need to go C:\xampp\mysql\bin section and open my.cnf or my.ini file and update the max_allowed_packet something like below.
After adding this restart the database server and run again the import sql file command.
You can import the sql file in database without getting any errors just paste the below command.
C:\xampp\mysql\bin>mysql -u root -p --max_allowed_packet=1073741824 openhouz < "C:\Users\Trilok\Downloads\openhouz.sql"
After running this command you absolutly import your sql file in database using command line in windows xampp server easily. If you got any error please specify the comment below.