10

Ant タスクを使用して MySQL データベースをダンプする方法に関する情報が見つかりませんでした。

これを行うには、独自のタスクを作成する必要がありますか?

ANT script ===generate==> myDataBase.sql
4

4 に答える 4

23

次のように「mysqldump」コマンドを実行するターゲットを作成します。

<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>  

ant dump-databaseを実行してダンプを作成できるようになりました

于 2009-09-11T13:26:26.677 に答える
2

ダンプに必要なすべてのアクションを実行するスクリプトを開始する Exec タスクを使用できます。

于 2009-09-11T13:22:02.693 に答える
0

データ駆動型にしたい場合は、ant sql タスクを使用してこの男を試してください。

<macrodef name="sql-retrieve-table-schema">
    <attribute name="schema-name"/>
    <attribute name="table-name"/>
    <attribute name="connection-url"/>
    <attribute name="output-file"/>
    <sequential>
        <sql userid="username" url="@{connection-url}"  classpathref="compile.classpath"
            password="apassword" driver="com.mysql.jdbc.Driver" print="true" output="@{output-file}"
            showheaders="false" showtrailers="false">
            SHOW CREATE TABLE @{table-name};
        </sql>
    </sequential>
</macrodef>
于 2015-11-26T01:57:37.343 に答える