Skip to content

Instantly share code, notes, and snippets.

@akullpp
Last active August 29, 2015 14:11
Show Gist options
  • Save akullpp/b37acbe7cd6e40f282c9 to your computer and use it in GitHub Desktop.
Save akullpp/b37acbe7cd6e40f282c9 to your computer and use it in GitHub Desktop.
Extract WordPress posts from MySQL

Step 1: Import SQL backup:

mysql -u root wp_dump < backup.sql

Step 2: Login:

mysql -u root

Step 3: Use database:

use wp_dump;

Step 4 (optional): Show tables:

show tables;

Step 5 (optional): Show columns in post table:

show columns from wp_posts;

Step 6: Extract title, date and content of all published posts into an external file:

select post_title, post_date, post_content from wp_posts
where post_status like "publish"
into outfile "~/export.txt"
fields terminated by "\n+++++++++++++++++++++++++++++\n"
escaped by "";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment