To delete MySQL database using Ant, do the followings:
- Save the XML code below in a file, e.g.
delete_database.xml
. - Change
mydatabasename
from the XML code below to the database name that you want to delete. - Run the following from Command prompt:
ant -f delete_database.xml
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <project basedir="." default="delete_db" name="Delete a database in mysql using Ant"> <!-- The following properties need to be changed according to your environment.--> <property name="mysqladmin" value="C:\wamp\bin\mysql\mysql5.1.36\bin\mysqladmin.exe"/> <property name="mysql.username" value="root"/> <property name="mysql.pwd" value="mypassword"/> <property name="mysql.dbname" value="mydatabasename"/> <!-- mysqladmin is used to delete a database. --> <target name="delete_db"> <exec executable="${mysqladmin}"> <arg value="--user=${mysql.username}"/> <arg value="--password=${mysql.pwd}"/> <arg value="--force"/> <arg value="DROP"/> <arg value="${mysql.dbname}"/> </exec> </target> </project>