开发者

Issue automating mysqldump using C#

I'd like to automate the process of copying a database from a remote server, to a local server. When I run this in the command prompt, it works fine:

mysqldump -h [remote server] -u [remote user] -p[password] --compress=FALSE --skip-lock-tables=TRUE --skip-add-locks=TRUE [db name] [list of tables I want to copy] | mysql -u root [db name]

I'm trying to automate this using C#, using the standard Process.Start(), but I'm getting an error, "Got error: 1045: Access denied for user 'root'@'rrcs-[some ip address].nyc.biz.rr.com (using password:开发者_StackOverflow社区 NO) when trying to connect.

If I modify the command line and remove "| mysql -u root [db name]" it runs (it just doesn't do what I want). It appears that the | is throwing things off. What's special about |, what can I do to get around this?

EDIT: If I use process explorer, I can see that C# is failing to pass any command line arguments to mysqldump. I don't think the problem is mysqldump, I think the problem is that process.start() cannot handle special characters in the arguments.


I think you are trying to pipe the output of mysqldump into another process, which does not exist. I found this, which explains how to pipe the output. It ain't pretty:

http://channel9.msdn.com/Forums/TechOff/202091-ProcessStartInfo-pipe-output-to-another-exe


Mysql is potentially seeing connection from different hosts;

Localhost/netbios when using mysqldump;

rrcs-[some ip address].nyc.biz.rr.com when using Process.Start()

try adding the permissions for 'root'@'rrcs-[some ip address].nyc.biz.rr.com' to match those of 'root'@'localhost'/'root'@'machinename'

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜