{"id":1037,"date":"2012-02-08T16:12:25","date_gmt":"2012-02-08T15:12:25","guid":{"rendered":"http:\/\/kudzia.eu\/b\/?p=1037"},"modified":"2025-10-10T08:21:54","modified_gmt":"2025-10-10T07:21:54","slug":"extracting-single-database-from-a-large-mysqldump","status":"publish","type":"post","link":"https:\/\/kudzia.eu\/b\/2012\/02\/extracting-single-database-from-a-large-mysqldump\/","title":{"rendered":"extracting single database from a [large] mysqldump or pg_dump"},"content":{"rendered":"<p>MySQL:<\/p>\n<p>extracting the whole database:<\/p>\n<pre>sed -n '\/^-- Current Database: `databaseName`\/,\/^-- Current Database: `\/p' \/path\/to\/the\/fill\/dump.sql  &gt; output.sql\r\n<\/pre>\n<p>single table:<\/p>\n<pre>sed -n '\/^CREATE TABLE `tableName`\/,\/^\\-\\- Table structure for table \/p' \/path\/to\/the\/fill\/dump.sql  &gt; output.sql\r\n<\/pre>\n<p>[via <a href=\"http:\/\/pento.net\/2009\/04\/16\/extracting-a-database-from-a-mysqldump-file\/\">this<\/a> blog]<\/p>\n<p>&nbsp;<\/p>\n<p>PostgreSQL:<\/p>\n<pre>pv dump.sql | perl -ne 'print if \/^COPY public.name_of_the_table\/ .. \/^\\\\\\.$\/' &gt; out.sql<\/pre>\n<p>[ via <a href=\"https:\/\/stackoverflow.com\/a\/62289905\">https:\/\/stackoverflow.com\/a\/62289905<\/a> ]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>MySQL: extracting the whole database: sed -n &#8216;\/^&#8211; Current Database: `databaseName`\/,\/^&#8211; Current Database: `\/p&#8217; \/path\/to\/the\/fill\/dump.sql &gt; output.sql single table: sed -n &#8216;\/^CREATE TABLE `tableName`\/,\/^\\-\\- Table structure for table \/p&#8217; \/path\/to\/the\/fill\/dump.sql &gt; output.sql [via this blog] &nbsp; PostgreSQL: pv dump.sql | perl -ne &#8216;print if \/^COPY public.name_of_the_table\/ .. \/^\\\\\\.$\/&#8217; &gt; out.sql [ via https:\/\/stackoverflow.com\/a\/62289905 ]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17,51],"tags":[12],"class_list":["post-1037","post","type-post","status-publish","format-standard","hentry","category-tech","category-unimportant","tag-mysql"],"_links":{"self":[{"href":"https:\/\/kudzia.eu\/b\/wp-json\/wp\/v2\/posts\/1037","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kudzia.eu\/b\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kudzia.eu\/b\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kudzia.eu\/b\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kudzia.eu\/b\/wp-json\/wp\/v2\/comments?post=1037"}],"version-history":[{"count":7,"href":"https:\/\/kudzia.eu\/b\/wp-json\/wp\/v2\/posts\/1037\/revisions"}],"predecessor-version":[{"id":3814,"href":"https:\/\/kudzia.eu\/b\/wp-json\/wp\/v2\/posts\/1037\/revisions\/3814"}],"wp:attachment":[{"href":"https:\/\/kudzia.eu\/b\/wp-json\/wp\/v2\/media?parent=1037"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kudzia.eu\/b\/wp-json\/wp\/v2\/categories?post=1037"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kudzia.eu\/b\/wp-json\/wp\/v2\/tags?post=1037"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}