Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I dump a MySQL database using ant?

I couldn't find any information about how to dump a MySQL database with an ant task.

Do I have to create my own task to do this?

ANT script ===generate==> myDataBase.sql
like image 762
Martin Magakian Avatar asked Sep 11 '09 13:09

Martin Magakian


People also ask

Which command is used to dump database?

To dump entire databases, do not name any tables following db_name , or use the --databases or --all-databases option. To see a list of the options your version of mysqldump supports, issue the command mysqldump --help .


1 Answers

Create a target that runs the "mysqldump" command like this:

<target name="dump-database">  
    <exec executable="mysqldump" output="database-dump.sql">  
        <arg value="--user=username" />  
        <arg value="--password=password" />  
        <arg value="--host=localhost" />  
        <arg value="--port=3306" />  
        <arg value="mydatabase" />  
    </exec>  
</target>  

Now you can make the dump by executing ant dump-database

like image 190
Tom van Zummeren Avatar answered Sep 19 '22 21:09

Tom van Zummeren