Import mysql db using command line is very simple statements and it effective and fast compare to importing huge database from phpmyadmin. There are one more advantage using this method the default mysql db upload file size is doesn’t a matter using command line.
Sometime we may face such a situation , importing huge DB from phpmyadmin the file size may exceed we know that the solution is changing the php.ini inside Xampp\php or Wamp\php folder. by changing following line you can increase the import DB file size. Then simply restart your Apache server.
post_max_size = 800M upload_max_filesize = 800M max_execution_time = 5000 max_input_time = 5000 memory_limit = 1000M
I think this is little complicated bcoz changing all this values and restarting Apache service. So our requirement is simply import a huge DB simply open up the command line prompt.
Windows + R will open a Run window in windows machine , Type “cmd” in that. It will open up a black color window. by default the path on this window is your Windows installation so change it , If your Apache installation is in different path using CD command .
here my Apache installation is in D drive so setting the path like follows, Also I’m using Xampp for windows so default mysql.exe path is D:\xampp\mysql\bin\mysql.exe
c:\users\my name\ //by default this is found. d: //press enter will set the directory to D drive. d:\>cd xampp\mysql\bin\ //press enter mysql:\> mysql -u DB_user_name -p // DB_user_name is your database user name by default root press enter it will prompt for a password if using root and password null simply press enter.Then you can simple create db using following statements mysql:\> create database db_name; mysql:\>use db_name; //press enter to use that DB. mysql:\>source d:\xampp\htdocs\t1\db.sql; // Full path to your db file press enter.
Hope this will simply import your DB successfully, For export DB using command line you can also use something like below.
mysq:\> mysql -u user_name -p password your_db_name your_table_name > export_file_name.sql
Its pretty simple right ? I hope you will be able to import mysql db using command line successfully .
thanks for reading :).