MySQL start interactive mode with a script

114 views Asked by At

How can I start mysql interactive mode from the command line, with a list of commands to run one-by-one at different prompts as if I had typed them?

printf "use my_db;\nselect * from my_table;\n" | mysql -u root -p doesn't work, I guess because mysql detects it's not running in a tty

And I can't try

printf "use my_db;\nselect * from my_table;\n" | script -qfec "mysql -u root -pMyPassword" /dev/null

because the docker container I'm in has no script command

0

There are 0 answers