go调用系统命令

package main

import(
    "fmt"
    "os/exec"
)

func main(){    
    //c := exec.Command("cmd", "/C", "mysqldump -uroot -p654321 -h127.0.0.1 -P3306 db_cow > d:/db_cow.sql")
    c := exec.Command("cmd", "/C", "mysql -uroot -p654321 -h127.0.0.1 -P3306 db_cow < d:/db_cow.sql")

    if err := c.Run(); err != nil { 
        fmt.Println("Error: ", err)
    }   
}

你可能感兴趣的:(go调用系统命令)