Post image for Merge MySQL *.sql files with Windows

Merge MySQL *.sql files with Windows

28/03/2011

in Website Backup Tips

With Website 2 Backup the backup of each of your MySQL tables is done in one *.sql file. We will see a solution to merge several *.sql files with Windows, to import them faster with phpMyAdmin.

You can have several tables to import in a MySQL database with phpMyAdmin.  With the phpMyAdmin import functionality you can import your tables using *.sql files. It is fast if you have few sql tables but if you have tens it will be time consuming. The solution is to merge all your *.sql files in one file. We will explain here how to merge all your *.sql files in one using Windows commands.

  1. In Windows  Start > Accessories > Execute, a windows appear
  2. Type cmd and hit enter a DOS windows appear
  3. You can see at the left of the command line where you are in your directories. You can use the dir command to see files and subdirectories of your actual directory. Using the commands cd.. and cd directory_name go to the directory where are your *.sql files to merge. you can use the command help cd to have more informations about it.

I have found a faster way to open the Command Prompt in the right directory with the contest menu.

  1. In your files explorer go to the directory where are your files to merge.
  2. Hold the SHIFT key while you right-click the folder and click on “Open Command Prompt Here”
  3. In the Command Prompt enter : copy *.sql merged.sql hit Enter to copy all data into merged.sql
  4. Close the Command Prompt window.
  5. Open merged.sql in your favorite sql editor and go to the bottom of the content to check if  Windows has added an unwanted character, remove it if needed.

All your *.sql are merged into merged.sql you can now import them with few clicks in phpMyAdmin.

This post has been updated the 2012-03-30

{ 1 comment… read it below or add one }

Henrietta June 27, 2011 at 16:49

Your asnwer was just what I needed. It’s made my day!

Reply

Leave a Comment

Previous post:

Next post: