simply would like to restart a MySQL5.6 server in a python script, on Windows 7. The server has a password
In a cmd prompt, I can stop the server using:
"C:\Program Files\MySQL\MySQL Server 5.6\bin\mysqladmin" -u root -p shutdown
The answer is as follows:
Run cmd.exe as Administrator by 1) right clicking on cmd.exe and selecting 'Run as Administrator', or 2) if you want to run the batch file from Task Scheduler, you will need to create a shortcut to the batch file, and then right click on the shortcut, select properties, select shortcut, and check off the run as administrator box. Then run the shortcut in Task scheduler.
In your batch file, which will now run as administrator, you use:
net stop MySQL56
net start MySQL56
where MySQL56 is the name of your MySQL service.
Of course you can easily run the batch file or shortcut from within python also.
Works on my Windows 7 x64...