Neil Aggarwal
Neil Aggarwal

Reputation: 511

Control Windows Command Prompt from Python

I am trying to programmatically shut down mysqld from python on a windows 7 machine.

I have tried the following commands in windows command prompt manually:

"C:\Program Files\MySQL\MySQL Server 5.1\bin\mysqladmin" -u demo shutdown -p demopw

I then receive the following prompt:

Enter Password:

After I manually type in the password, mysqld shuts down.

My problem is, I need to do this automatically within python. I have read one or two other posts that I could find, and have searched for quite a while for an answer that works. Thus far, I have tried many variations with popen, and subprocess.Popen, to no avail.

Thanks in advance.

Upvotes: 0

Views: 111

Answers (1)

AKX
AKX

Reputation: 169368

The -p argument to mysql and mysqladmin et al is funky in that you absolutely can not have a space between the -p and the password.

So try

"C:\Program Files\MySQL\MySQL Server 5.1\bin\mysqladmin" -u demo -pdemopw shutdown

Upvotes: 1

Related Questions