如何在java上使用mysqldump? [英] how to mysqldump on java?
本文介绍了如何在java上使用mysqldump?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在mySQL中创建了数据库,然后使用mysqldump将其导出到一个文件中。
有没有办法让我的程序在JAVA上连接mysql并用我保存在文件中的stracture创建一个空数据库,只有上述数据库不是已经存在于服务器中?
谢谢!
I made my database in mySQL and I exported it in a file using mysqldump. Is there a way to make my program on JAVA to connect in mysql and create an empty database with the stracture I saved in the file, only if the above database is not allready exist to the server? Thank you!
推荐答案
尝试类似:
Runtime.getRuntime().exec("mysql -u <username> -p<password> <youdbname> < <youbackupfile>");
您需要更换< username>
使用您的用户名/ < password>
使用您的密码/ < yourdbname>
并附上您的数据库名称/ < yourbackupfile>
包含用于备份的文件
you will need to replace <username>
with your username / <password>
with your password / <yourdbname>
with you database name / <yourbackupfile>
with the file you used for backup
这篇关于如何在java上使用mysqldump?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文