| 123456789101112131415161718192021 |
- /**
- * Test$
- *
- * @author wukai
- * @date 2023/11/14 15:13
- */
- public class Test {
- public static void main(String[] args) {
- try {
- String cmd = " /usr/local/mysql/bin/mysqldump -h192.168.1.28 -P3306 -uroot -p123456 --default-character-set=utf8 doc >/tmp/test.sql";
- Process exec = Runtime.getRuntime().exec(cmd);
- if (exec.waitFor() == 0) {
- System.out.println("数据库备份成功");
- } else {
- System.out.println("process.waitFor()=" + exec.waitFor());
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
|