# Tool to extract single database from a SQL dump file?

**URL:** <https://boards.straightdope.com/t/tool-to-extract-single-database-from-a-sql-dump-file/619645>\
**Category:** In My Humble Opinion\
**Created:** [April 23, 2012, 12:30am UTC](https://boards.straightdope.com/t/tool-to-extract-single-database-from-a-sql-dump-file/619645 "2012-04-23T00:30:05Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![gaffa](https://avatars.discourse-cdn.com/v4/letter/g/e68b1a/32.png) [@gaffa](https://boards.straightdope.com/u/gaffa)\
**Post date:** [April 23, 2012, 12:30am UTC](https://boards.straightdope.com/t/tool-to-extract-single-database-from-a-sql-dump-file/619645/1 "2012-04-23T00:30:05Z")

</div>

I’m trying to move a Wordpress web site from one host to another. The hard part is that I don’t have access to the original site, and the person who created the site is being a pain. I needed the database of the site, and he sent me the localhost.sql - 30 megs of unrelated crap. So it exceeds the 7 meg limit of the MySQL web tools, and none of the text tools I’ve found have worked.

Any suggestions for a tool, preferably on Windows, that will allow me to load in this 30 meg file and extract the one database I need?

---

<div class="post-metadata">

**Author:** ![Fuzzy\_Dunlop](https://avatars.discourse-cdn.com/v4/letter/f/848f3c/32.png) [@Fuzzy\_Dunlop](https://boards.straightdope.com/u/Fuzzy_Dunlop)\
**Post date:** [April 23, 2012, 1:27am UTC](https://boards.straightdope.com/t/tool-to-extract-single-database-from-a-sql-dump-file/619645/2 "2012-04-23T01:27:37Z")

</div>

> [@gaffa](#):
>
> I’m trying to move a Wordpress web site from one host to another. The hard part is that I don’t have access to the original site, and the person who created the site is being a pain. I needed the database of the site, and he sent me the localhost.sql - 30 megs of unrelated crap. So it exceeds the 7 meg limit of the MySQL web tools, and none of the text tools I’ve found have worked.
> 
> Any suggestions for a tool, preferably on Windows, that will allow me to load in this 30 meg file and extract the one database I need?

Is there anything wrong with:

```auto

mysql -uuser -ppassword dbname < localhost.sql

```

---

<div class="post-metadata">

**Author:** ![gaffa](https://avatars.discourse-cdn.com/v4/letter/g/e68b1a/32.png) [@gaffa](https://boards.straightdope.com/u/gaffa)\
**Post date:** [April 23, 2012, 1:43am UTC](https://boards.straightdope.com/t/tool-to-extract-single-database-from-a-sql-dump-file/619645/3 "2012-04-23T01:43:34Z")

</div>

> [@Fuzzy\_Dunlop](#):
>
> Is there anything wrong with:
> 
> ```auto
> 
> mysql -uuser -ppassword dbname < localhost.sql
> 
> ```

Yeah, didn’t work. Kept getting an empty file.

The situation is made more difficult by the fact that this is on Dreamhost, and the MySQL server is on a different machine.

---

<div class="post-metadata">

**Author:** ![andrewm](https://avatars.discourse-cdn.com/v4/letter/a/c57346/32.png) [@andrewm](https://boards.straightdope.com/u/andrewm)\
**Post date:** [April 23, 2012, 1:54am UTC](https://boards.straightdope.com/t/tool-to-extract-single-database-from-a-sql-dump-file/619645/4 "2012-04-23T01:54:01Z")

</div>

You could install a copy of MySQL Server (it’s a free download) on your local Windows machine, load the full dump, and then dump out just the database you want.

---

<div class="post-metadata">

**Author:** ![gaffa](https://avatars.discourse-cdn.com/v4/letter/g/e68b1a/32.png) [@gaffa](https://boards.straightdope.com/u/gaffa)\
**Post date:** [April 23, 2012, 2:01am UTC](https://boards.straightdope.com/t/tool-to-extract-single-database-from-a-sql-dump-file/619645/5 "2012-04-23T02:01:04Z")

</div>

sed didn’t work either.

---

<div class="post-metadata">

**Author:** ![gaffa](https://avatars.discourse-cdn.com/v4/letter/g/e68b1a/32.png) [@gaffa](https://boards.straightdope.com/u/gaffa)\
**Post date:** [April 23, 2012, 2:05am UTC](https://boards.straightdope.com/t/tool-to-extract-single-database-from-a-sql-dump-file/619645/6 "2012-04-23T02:05:24Z")

</div>

I’ve been attempting to you the instructions [here](http://wiki.dreamhost.com/Migrate_MySQL#Importing_Through_the_Shell), and I get a zero byte target file.

---

<div class="post-metadata">

**Author:** ![gaffa](https://avatars.discourse-cdn.com/v4/letter/g/e68b1a/32.png) [@gaffa](https://boards.straightdope.com/u/gaffa)\
**Post date:** [April 23, 2012, 2:10am UTC](https://boards.straightdope.com/t/tool-to-extract-single-database-from-a-sql-dump-file/619645/7 "2012-04-23T02:10:42Z")

</div>

MySQL keeps giving me ERROR 1044 (42000):

Amusingly obscure the first few hundred times, after that you start getting annoyed.

So, any solutions that do NOT involve MySQL?

---

<div class="post-metadata">

**Author:** ![Fuzzy\_Dunlop](https://avatars.discourse-cdn.com/v4/letter/f/848f3c/32.png) [@Fuzzy\_Dunlop](https://boards.straightdope.com/u/Fuzzy_Dunlop)\
**Post date:** [April 23, 2012, 2:16am UTC](https://boards.straightdope.com/t/tool-to-extract-single-database-from-a-sql-dump-file/619645/8 "2012-04-23T02:16:09Z")

</div>

> [@gaffa](#):
>
> MySQL keeps giving me ERROR 1044 (42000):
> 
> Amusingly obscure the first few hundred times, after that you start getting annoyed.
> 
> So, any solutions that do NOT involve MySQL?

Dreamhost won’t allow you to run the commands in your sql file. Easiest bet would be to take **andrewm** ’s advice and load the data into an MySQL server running on your local machine and then export exactly what you want for Dreamhost.

---

<div class="post-metadata">

**Author:** ![gaffa](https://avatars.discourse-cdn.com/v4/letter/g/e68b1a/32.png) [@gaffa](https://boards.straightdope.com/u/gaffa)\
**Post date:** [April 23, 2012, 2:40am UTC](https://boards.straightdope.com/t/tool-to-extract-single-database-from-a-sql-dump-file/619645/9 "2012-04-23T02:40:11Z")

</div>

> [@Fuzzy\_Dunlop](#):
>
> Dreamhost won’t allow you to run the commands in your sql file. Easiest bet would be to take **andrewm** ’s advice and load the data into an MySQL server running on your local machine and then export exactly what you want for Dreamhost.

I installed the hateful thing on my computer, and am trying to puzzle out the syntax. As usual for Unix style utilities, the “help” file exists solely as a reminder for the person who wrote the program.

---

<div class="post-metadata">

**Author:** ![tellyworth](https://avatars.discourse-cdn.com/v4/letter/t/977dab/32.png) [@tellyworth](https://boards.straightdope.com/u/tellyworth)\
**Post date:** [April 23, 2012, 4:09am UTC](https://boards.straightdope.com/t/tool-to-extract-single-database-from-a-sql-dump-file/619645/10 "2012-04-23T04:09:00Z")

</div>

For a one-off job, you can split a mysql dump file up with any decent text editor. The division between the tables ought to be plain enough.

Also, the phpmysql Import feature will accept a compressed file. It’s unlikely a 30mb file would compress to 7, but worth a try.

For future reference, WordPress has an export feature.
