Powered By

Play with mysql import, export operations


We can easily do import/export operations in mysql very easily. Here is the example for both.


In some cases you may have to have backup of your database and you want to use it some other server.


In such cases you just follow the instructions given below.


You can do the mysql import, export operations in two ways.


  1. If you are having phpmyadmin like interface to access your mysql means, it will be very easier.


Just access the phpmyadmin from your browser(domainname/phpmyadmin)







Once you provided authentication its all done.



Choose a database which you want to export






In the top you can find import,export options.






You can export to many number of formats



Once you chosen a format and tables which are to export means it will ask you to save the file. Export is over.


You can import sql files easily from here,



It has a disadvantage too. If your database is too big there will be time out problem.


In such case you can follow the below one or just contact your hosting company to do this.








  1. And also you can do export, import operations from command line very easily without any of the above conditions.


Here you need to ssh access in case if you are accessing the remote server or if it is local you just need terminal.


First export the existing database by using the below command


mysql -u USERNAME -p DATABASENAME > FILE.SQL


Once you have the sql file means yoou can import the sql file by


mysql -u USERNAME -p DATABASENAME < FILE.SQL


Here you need to provide password to access


For example



mysql -u root -p forum < forumdb.sql



It will be stored in your present directory.




mysql -u root -p forum < forumdb.sql
The sql file should be in the present directory.


Leave your comments….

Related Posts by Categories