mysql - unix command execution with password via python -
i trying connect mysql in unix python script. provided password connect mysql in script terminal still prompts password. have till now:
import os subprocess import popen, pipe passwd = "user" command = "mysql -u root -p" proc = popen(command.split(), stdin=pipe) proc.communicate(passwd+'\n')[1]
can 1 suggest doing wrong here. or there better way this.
i tried script in ubuntu 14.04. easy start mysql in terminal using shell script. here code..
#!/bin/bash user=('root') pass=('xxx') mysql -u $user -p$pass echo 'success'
simply run code & can start mysql @ terminal...