online prescription solutions
online discount medstore
pills online
buy lorazepam without prescription
xanax for sale
buy xanax without prescription
buy ambien without prescription
ambien for sale
buy modafinil without prescription
buy phentermine without prescription
modafinil for sale
phentermine for sale
lorazepam for sale
buy lexotan without prescription
bromazepam for sale
xenical for sale
buy stilnox without prescription
valium for sale
buy prosom without prescription
buy mefenorex without prescription
buy sildenafil citrate without prescription
buy adipex-p without prescription
librium for sale
buy restoril without prescription
buy halazepam without prescription
cephalexin for sale
buy zoloft without prescription
buy renova without prescription
renova for sale
terbinafine for sale
dalmane for sale
buy lormetazepam without prescription
nobrium for sale
buy klonopin without prescription
priligy dapoxetine for sale
buy prednisone without prescription
buy aleram without prescription
buy flomax without prescription
imovane for sale
adipex-p for sale
buy niravam without prescription
seroquel for sale
carisoprodol for sale
buy deltasone without prescription
buy diazepam without prescription
zopiclone for sale
buy imitrex without prescription
testosterone anadoil for sale
buy provigil without prescription
sonata for sale
nimetazepam for sale
buy temazepam without prescription
buy xenical without prescription
buy famvir without prescription
buy seroquel without prescription
rivotril for sale
acyclovir for sale
loprazolam for sale
buy nimetazepam without prescription
buy prozac without prescription
mogadon for sale
viagra for sale
buy valium without prescription
lamisil for sale
camazepam for sale
zithromax for sale
buy clobazam without prescription
buy diflucan without prescription
modalert for sale
diflucan for sale
buy alertec without prescription
buy zyban without prescription
buy serax without prescription
buy medazepam without prescription
buy imovane without prescription
mefenorex for sale
lormetazepam for sale
prednisone for sale
ativan for sale
buy alprazolam without prescription
buy camazepam without prescription
buy nobrium without prescription
mazindol for sale
buy mazindol without prescription
buy mogadon without prescription
buy terbinafine without prescription
diazepam for sale
buy topamax without prescription
cialis for sale
buy tafil-xanor without prescription
buy librium without prescription
buy zithromax without prescription
retin-a for sale
buy lunesta without prescription
serax for sale
restoril for sale
stilnox for sale
lamotrigine for sale

MySQL: How do I import individual table dump files in to MySQL using shell script?


After I wrote the post: How do I dump all tables in a database into separate files? I got emails from couple people asking how to import the individual table files back in to MySQL. First way to import each sql file created by the post is to import each file individually by typing:mysql db_name < table1.sql This will work as long as you are only importing few files. But if you need to import all of the files in the directory, which could be in 100’s, this method does not scale well. To achieve this I wrote a shell script which does the work for me. Of course, there are other ways to do this and I am only showing you one way of doing it. This works for me so here it is:

#!/bin/bash
db=$1
if [ "$db" = "" ]; then
echo "Usage: $0 db_name"
exit 1
fi
mkdir done
clear
for sql_file in *.sql; do
echo "Importing $sql_file";
mysql $db< $sql_file;
mv $sql_file done;
done

Related posts:

————————————-
DISCLAIMER: Please be smart and use code found on internet carefully. Make backups often. And yeah.. last but not least.. I am not responsible for any damage caused by this posting. Use at your own risk.


7 Responses to “ MySQL: How do I import individual table dump files in to MySQL using shell script? ”

  1. November 29th, 2007 | 11:13 am

    Why not just do…

    cat *.sql |mysql db_name

  2. December 1st, 2007 | 1:07 pm

    Initially, that is what I did. But somewhere along the line, my import failed. I had no idea where it failed and had to start importing from the beginning. Using the script gives me status and makes it easy for me continue where ever mysql import breaks/stops.

  3. December 15th, 2007 | 7:40 am

    Is there any way to dumping selected rows only from a table.
    I have a table with 70000 rows, and I want to dump about 6000 rows which meets certain criteria.

    it should be some thing like where in
    field = x1
    field = x3
    field = x4
    ….

    I just do not know whole syntax.

    Thanks

  4. February 4th, 2008 | 2:58 pm

    [...] How do I import individual table dump files in to MySQL using shell script? [...]

  5. December 16th, 2009 | 2:53 pm

    [...] MySQL: How do I import individual table dump files in to MySQL using shell script? [...]

  6. Subhasri
    July 12th, 2011 | 1:44 am

    How to import Sql tables into MySQL?

  7. April 13th, 2012 | 10:05 am

    Hi

    Please provide the solution:

    I have 2 database in SQL server(VISH & KALM)

    VISH database is having 100 tables & KALM database is 10 tables.
    Now, i need to import all tables of KALM database to VISH database

    Note:VISH & KALM database is having simmilar tables.

Leave a reply

*
To prove that you're not a bot, enter this code
Anti-Spam Image