1

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

Shadow
  • 33,525
  • 10
  • 51
  • 64
theonlygusti
  • 11,032
  • 11
  • 64
  • 119
  • 1
    MySQL has an option `--init-command` but unfortunately, [it doesn't work](https://bugs.mysql.com/bug.php?id=27885) (that bug has been open since 2007). – Bill Karwin Apr 18 '23 at 16:31

0 Answers0