0

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.

1 Answer 1

1

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
Sign up to request clarification or add additional context in comments.

2 Comments

Wow. Thanks so much. Just want to note that there is no semicolon after shutdown for anyone who sees this in the future.
I have tried to use the above command using os.system(...), and it does not actually stop the server. Any ideas why?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.