Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm writing a Windows batch file. On the ordinary command line, we'd have:

mysql -u root -p dbname
Enter password: [types password]
show tables;

Is there a way I can supply the password, and 'show tables' in the batch file so the user doesn't have to type it in - they can just run the batch file?

share|improve this question

1 Answer 1

Password:

mysql -u root --password=p4ssw3rd dbname

Commands:

mysql ... -e "show tables;"
echo show tables; | mysql ...
(
    echo foo;
    echo bar;
) | mysql ...
mysql ... < commands.txt
share|improve this answer
    
very good! i normally use "<" –  kokbira Jun 26 '11 at 4:00

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.