starting MySQL from python script -


im trying start mysql server python 3.4 script on max os x 10.10.4 yet don't know how pass super user password ?

import os  os.system("sudo /usr/local/mysql/support-files/mysql.server start")   sudo: no tty present , no askpass program specified 

you going in right direction. in system mysql server started /etc/init.d/mysql.

just use following code snippet run mysql server python script.

import os  os.system('sudo /etc/init.d/mysql start') 

the best way run root commands execute file root

simply type sudo python script.py in shell , can replace os.system('sudo /etc/init.d/mysql start') os.system('/etc/init.d/mysql start')


Comments