samadadi
(Saeed Madadi)
March 15, 2018, 2:44pm
1
I’m trying to run/load sql file into mysql database using this golang statement but this is not working:
exec.Command("mysql", "-u", "{username}", "-p{db password}", "{db name}", "<", file abs path )
But when i use following command in windows command prompt it’s working perfect.
mysql -u {username} -p{db password} {db name} < {file abs path}
So what is the problem?
calmh
(Jakob Borg)
March 15, 2018, 3:17pm
2
The redirection <
is a shell operation, but you’re not running a shell. You can open the file and pipe it yourself (see the Stdin thing on exec.Command), or you can write it as a shell script instead.
samadadi
(Saeed Madadi)
March 15, 2018, 3:21pm
3
Yes you’re right. Somebody asked me in stackoverflow with a nice way.
Answer link: https://stackoverflow.com/a/49303057/3858203
system
(system)
Closed
June 13, 2018, 3:22pm
4
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.