Unix Technical Forum

How to restore 1 database from mysqldump of all databases

This is a discussion on How to restore 1 database from mysqldump of all databases within the MySQL General forum forums, part of the MySQL category; --> Question: How do I restore 1 database from amysqldump of all databases? Obviously a newbie. I've searched the list ...


Go Back   Unix Technical Forum > Database Server Software > MySQL > MySQL General forum

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-28-2008, 06:47 AM
waldo_tumanut@americancentury.com
 
Posts: n/a
Default How to restore 1 database from mysqldump of all databases


Question: How do I restore 1 database from amysqldump of all databases?

Obviously a newbie. I've searched the list but couldn't find the answer.
Can someone help?

Waldo Tumanut
Database Analyst


------------------------------------------------------------
CONFIDENTIALITY NOTICE: This electronic mail transmission (including any accompanying attachments) is intended solely for its authorized recipient(s), and may contain confidential and/or legally privileged information. If you are not an intended recipient, or responsible for delivering some or all of this transmission to an intended recipient, be aware that any review, copying, printing, distribution, use or disclosure of the contents of this message is strictly prohibited. If you have received this electronic mail message in error, please contact us immediately by electronic mail at emailnotification@americancentury.com and destroy the original and all copies of this transmission (including any attachments).

Thank you.
------------------------------------------------------------
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-28-2008, 06:47 AM
Rolando Edwards
 
Posts: n/a
Default Re: How to restore 1 database from mysqldump of all databases

When the mysqldump ran against all databases, the USE <db-name> command should have appeared above each section of that databases dump. Try using Perl or the head or tail Unix command to hunt down the Database you are dumping. Read all lines until the next USE <db-name> command.

Example: If you mysqldumped databases DB1, DB2 (copyright IBM), DB3, DB4, and DB5
and you want ot restore just DB3, locate the string "USE DB3" (say its line 200000)
and "USE DB4" (say its line 250000). Copy lines 200000 to 250000 to another SQL script.
Then run that new script.


----- Original Message -----
From: "waldo tumanut" <waldo_tumanut@americancentury.com>
To: mysql@lists.mysql.com
Sent: Tuesday, July 10, 2007 9:34:28 AM (GMT-0500) America/New_York
Subject: How to restore 1 database from mysqldump of all databases


Question: How do I restore 1 database from amysqldump of all databases?

Obviously a newbie. I've searched the list but couldn't find the answer.
Can someone help?

Waldo Tumanut
Database Analyst


------------------------------------------------------------
CONFIDENTIALITY NOTICE: This electronic mail transmission (including any accompanying attachments) is intended solely for its authorized recipient(s), and may contain confidential and/or legally privileged information. If you are not an intended recipient, or responsible for delivering some or all of this transmission to an intended recipient, be aware that any review, copying, printing, distribution, use or disclosure of the contents of this message is strictly prohibited. If you have received this electronic mail message in error, please contact us immediately by electronic mail at emailnotification@americancentury.com and destroy the original and all copies of this transmission (including any attachments).

Thank you.
------------------------------------------------------------

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=redwards@swmx.com


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-28-2008, 06:48 AM
Mogens Melander
 
Posts: n/a
Default Re: How to restore 1 database from mysqldump of all databases

A quick script solution:

create a dump pr. table in <db>.

#!/bin/bash

for tbl in `echo "use <db>;show tables;"|mysql -s -u <user> -p<password>`
do
mysqldump -u <user> p<password> db $tbl > $tbl.sql
done

and the other way:

cat <tbl.sql>| mysql -u <user> -p<password> <db>

On Tue, July 10, 2007 15:47, Rolando Edwards wrote:
> When the mysqldump ran against all databases, the USE <db-name> command
> should have appeared above each section of that databases dump. Try using
> Perl or the head or tail Unix command to hunt down the Database you are
> dumping. Read all lines until the next USE <db-name> command.
>
> Example: If you mysqldumped databases DB1, DB2 (copyright IBM), DB3, DB4,
> and DB5
> and you want ot restore just DB3, locate the string "USE DB3" (say its
> line 200000)
> and "USE DB4" (say its line 250000). Copy lines 200000 to 250000 to
> another SQL script.
> Then run that new script.
>
>
> ----- Original Message -----
> From: "waldo tumanut" <waldo_tumanut@americancentury.com>
> To: mysql@lists.mysql.com
> Sent: Tuesday, July 10, 2007 9:34:28 AM (GMT-0500) America/New_York
> Subject: How to restore 1 database from mysqldump of all databases
>
>
> Question: How do I restore 1 database from amysqldump of all databases?
>
> Obviously a newbie. I've searched the list but couldn't find the answer.
> Can someone help?
>
> Waldo Tumanut
> Database Analyst
>
>
> ------------------------------------------------------------
> CONFIDENTIALITY NOTICE: This electronic mail transmission (including any
> accompanying attachments) is intended solely for its authorized
> recipient(s), and may contain confidential and/or legally privileged
> information. If you are not an intended recipient, or responsible for
> delivering some or all of this transmission to an intended recipient, be
> aware that any review, copying, printing, distribution, use or disclosure
> of the contents of this message is strictly prohibited. If you have
> received this electronic mail message in error, please contact us
> immediately by electronic mail at emailnotification@americancentury.com
> and destroy the original and all copies of this transmission (including
> any attachments).
>
> Thank you.
> ------------------------------------------------------------
>
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe: http://lists.mysql.com/mysql?unsub=redwards@swmx.com
>
>
>
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe: http://lists.mysql.com/mysql?unsub=mogens@fumlersoft.dk
>
>
> --
> This message has been scanned for viruses and
> dangerous content by MailScanner, and is
> believed to be clean.
>



--
Later

Mogens Melander
+45 40 85 71 38
+66 870 133 224



--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-28-2008, 06:48 AM
waldo_tumanut@americancentury.com
 
Posts: n/a
Default Re: How to restore 1 database from mysqldump of all databases

Thanks to all who have replied. Since this thread has evolved into
discussing the dump, I would like to ask the group what are their practices
for backup and recovery on Windows platform.

Waldo Tumanut
Database Analyst




"Mogens
Melander"
<mogens@fumlers To
oft.dk> "Rolando Edwards"
<redwards@swmx.com>
07/10/2007 cc
06:25 PM "waldo tumanut"
<waldo_tumanut@americancentury.co
m>, mysql@lists.mysql.com
Subject
Re: How to restore 1 database
from mysqldump of all databases










A quick script solution:

create a dump pr. table in <db>.

#!/bin/bash

for tbl in `echo "use <db>;show tables;"|mysql -s -u <user> -p<password>`
do
mysqldump -u <user> p<password> db $tbl > $tbl.sql
done

and the other way:

cat <tbl.sql>| mysql -u <user> -p<password> <db>





------------------------------------------------------------
CONFIDENTIALITY NOTICE: This electronic mail transmission (including any accompanying attachments) is intended solely for its authorized recipient(s), and may contain confidential and/or legally privileged information. If you are not an intended recipient, or responsible for delivering some or all of this transmission to an intended recipient, be aware that any review, copying, printing, distribution, use or disclosure of the contents of this message is strictly prohibited. If you have received this electronic mail message in error, please contact us immediately by electronic mail at emailnotification@americancentury.com and destroy the original and all copies of this transmission (including any attachments).

Thank you.
------------------------------------------------------------
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 09:10 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com