問題描述
我需要使用 ant 任務(wù)啟動(dòng)和停止 mysql 5.5.
I need to start and stop mysql 5.5 using ant task.
早期的 ANT 腳本是為 hsqldb 數(shù)據(jù)庫做的,它使用的類是 org.hsqldb.Server
.有人能告訴我 mysql 5.5 使用哪個(gè)類.
The earlier ANT script was doing it for hsqldb database for which the class it was using was org.hsqldb.Server
. Could someone tell me which class to use for mysql 5.5.
以下是在 hsqldb 用于 mydb 的情況下使用的:<java fork="true" spawn="true" classname="org.hsqldb.Server" classpathref="build.runtime.classpath"><arg line="-database.0 file:data/mydb -dbname.0 mydb"/></java>
Following was being use in case of hsqldb for mydb:
<java fork="true" spawn="true" classname="org.hsqldb.Server" classpathref="build.runtime.classpath">
<arg line="-database.0 file:data/mydb -dbname.0 mydb"/>
</java>
我需要 mysql 5.5 的等效項(xiàng).我知道連接器是用來連接mysql 5.5數(shù)據(jù)庫的,我用的是mysql-connector-java-5.1.15-bin.jar
.
I need to have the eqivalant for mysql 5.5. I know a connector is used to connect to mysql 5.5 database, I use mysql-connector-java-5.1.15-bin.jar
.
誰能告訴我如何使用 ant 腳本啟動(dòng)和停止 mysql 數(shù)據(jù)庫.
Could someone just tell me how to start and stop mysql database using an ant script.
謝謝.
推薦答案
將 MySQL 配置為 機(jī)器啟動(dòng)時(shí)自動(dòng)啟動(dòng).MySQL 旨在在后臺(tái)持續(xù)運(yùn)行.
It would be more normal to configure MySQL to automatically start when the machine boots. MySQL is designed to run continually in the background.
如果您真的想從 ANT 中停止和啟動(dòng) MySQL,則可以調(diào)用服務(wù)器腳本(當(dāng)然,假設(shè) MySQL 與構(gòu)建運(yùn)行在同一臺(tái)機(jī)器上).
If you really want to stop and start MySQL from within ANT it's possible to invoke the server scripts (Assuming of course MySQL is running on the same machine as the build).
<target name="start-db">
<exec executable="C:\Program Files\MySQL\MySQL Server 5.5\bin\mysqld" osfamily="windows">
</exec>
<exec executable="mysql.server" osfamily="unix">
<arg value="start"/>
</exec>
</target>
<target name="stop-db">
<exec executable="C:\Program Files\MySQL\MySQL Server 5.5\bin\mysqld" osfamily="windows">
<arg value="-u"/>
<arg value="root"/>
<arg value="shutdown"/>
</exec>
<exec executable="mysql.server" osfamily="unix">
<arg value="stop"/>
</exec>
</target>
注意:
- 此腳本包含在 windows 和 unix 上啟動(dòng)/停止的命令.
- MySQL 文檔描述了如何啟動(dòng) Mysql從 windows 命令行
這篇關(guān)于如何使用 ANT 任務(wù)啟動(dòng) MySql的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!