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.

AKX
171k17 gold badges148 silver badges230 bronze badges
asked Dec 4, 2014 at 10:50

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
answered Dec 4, 2014 at 10:53
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

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.