How to import export sql file from command line or ssh by putty
How to import export sql file from command line or ssh

I was trying to export a database file of big in size then I could not because max-time in server in less so that’s why I was getting timeout error then I searched a lot and got to know its a simple thing to upload and download database file .Its just take 5 to 10 sec to export a .sql file having size 150 to 250 MB.Then if .sql file a little high it may take another few sec .So is not it a simple way .This simple way is through command line.It can be done through putty if you are trying to access live data base and you have SSH credential details.Also If you want to do it on your localhost and you are using windows system you can do it through cmd and if you have Linux then command line.So lets see How to import export sql file from command line by some tricks and some command through which we can easily import and export .sql file.

Note: If you are trying to export and import through cmd and getting the error like mysql is not recognized as an internal or external command then you can set the path of your mysql location I mean you have to inform to system the location of mysql setup .For that you can do it by direct changing directory in cmd or setting path in environmental variable to system.Here I am not explaining all those things because this is not our topic.Leave that lets proceeds for different types of command.Also If you want to know how to set path in system environment variable and please feel free to comment below of this post to get the solution.

Note: Please don’t be confused I have used all example for my case having database name test password root and username root.

To Export:

If you want to export the entire database then :

If you want to export the entire database then :

If you your databse is so high and want compress then :

If you want to export a specific table within database then:

Those are all about localhost system means in your local system.But you have access to the server having mysql port number 22 then :

if you have dedicated databse server having some ipaddress then:

To Import:

To import is the simillar way to export but just use the symbole >(export) to <(Import)

If you want to import the entire database then :

If you want to import the entire database then :

Also another easy trick I can give you here.That is if you can access SQL shell then:

How to import export sql file from command line
The following two tabs change content below.
Jyotiranjan is one of passionate programmer who has been working in magento since 6 years and in the mean time he has developed enormous amount of modules and customisation of sites. He loves to write blogs and travel for long journeying.

Latest posts by Jyotiranjan Biswal (see all)

Tagged on:                         

Leave a Reply

Your email address will not be published. Required fields are marked *