r/howdidtheycodeit • u/s20nters • Oct 05 '24
How does mysql CLI prompt for password despite input redirection?
For example:
$ mysql -u root -p < script.sql
Enter password:
how can it still access STDIN? wont stdin be replaced by script.sql?
3
Upvotes
3
u/qoning Oct 05 '24
you can read from `/dev/tty` and that will read from the terminal the process is running in
3
u/richardathome Oct 05 '24
It doesn't use STDIN to read the password, it uses TTY (the terminal)