Negrazo has asked for the wisdom of the Perl Monks concerning the following question:

Dear perlmonks: I have a backup of my database, that I created with a Perl script, this gave me a "backup_20070329.sql" file. The question now is how can I restore my database with a perl script, not using MySQL client. Could you give me a hint???? Thanks in advance. Negrazo.

Replies are listed 'Best First'.
Re: Restoring a MySQL DB
by snoopy (Curate) on Apr 12, 2007 at 04:59 UTC
    You could use the run_restore_script method in MySQL::Backup.

    For example, the following will rebuild your database.

    #!/usr/bin/perl use strict; use warnings; use MySQL::Backup; my $filename = "backup_20070329.sql"; my $mb = new MySQL::Backup('mydb','127.0.0.1','user','password',{}); $mb->run_restore_script($filename);
    This completely replaces the database schema and repopulates the data.
      Hey snoopy: I saw your tip and immediately applied it to my application and it worked. I thank you for your time and support. I learned something new today. Thank's again. Negrazo.
A reply falls below the community's threshold of quality. You may see it by logging in.