[wp-hackers] best way to reset the database

Haluk Karamete halukkaramete at gmail.com
Sun Apr 8 15:45:20 UTC 2012


If I use the truncate on the tables I was to clear, it truncates it all the
way. It does not take me back to the fresh install. For example, doing
truncate on the "wp_term_taxonomy" table will get rid of the 2 taxonomies (
category + link_category) that comes with fresh install.

A more ideal solution is to backup from an exported xml file.

Something like this;

<?php
restore_from_backup($full_path_to_xml_file);
?>

Does anyone know how to make that happen?

Daniel earlier mentioned that

mysql -u #username#  -p #database# < #dump_file#

would restore the database.

But how do I do this from a PHP code?





On Wed, Apr 4, 2012 at 12:45 AM, Tom Barrett <tcbarrett at gmail.com> wrote:

> Inspired by: http://wordpress.org/extend/plugins/wordpress-reset/
>
> I have a theme I use for development that stores the
> options/posts/user/whatever, drops the tables, deletes uploads, rebuilds
> and inserts the data I want to keep. Not too tricky, but possibly overkill
> for hat you want.
>
> On 4 April 2012 08:04, Kokarn <kokarn at gmail.com> wrote:
>
> > Isn't the only problem that you want to totally reset two tables?
> >
> > In that case you could write a plugin that does "TRUNCATE TABLE wp_post"
> > and "TRUNCATE TABLE wp_post_meta".
> > That will delete all the data and reset the auto_increment values (if you
> > use any version of MySQL and a MyISM db or MySQL >= 5 and an INNODB db)
>
>
> If you all you want to do is clear out the posts and postmeta tables, then
> truncate is your friend. I'd go with this option from what you describe.
>
> --
> http://www.tcbarrett.com | http://gplus.to/tcbarrett |
> http://twitter.com/tcbarrett
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>


More information about the wp-hackers mailing list