Import/Export MySQL Database Using Command Line

Importing or Exporting a MySQL database sometimes using phpMyAdmin is a bit problematic especially if the size of your database exceed the maximum limit of PHP upload. Not only that, it is slow compare to using a command line interface. So to import and export a database only needs two simple programs called mysqldump and mysql itself. To export a database: mysqldump -u root -p products > d:\database\products.sql This will export a database called "products" to a file named products.sql To import a database: mysql -p -u root products < d:\database\products.sql This will import a database called "products" from a file named products.sql Note that the syntax is the same in linux box. Except that you have to change the correct path. In our example above, just change d:\database\products.sql to the location of the file in your linux box. Example: /home/database/products.sql instead of d:\database\products.sql

Add new comment