Running mysql client with password authentication in Bash script

51 Views Asked by At

I have the following goal: import an sql file from Git Bash in Windows inside a script. (I have mysql 8, but 5.7 the same as far as I tried.)

The commands, which I tried individually:

$ mysql -u root -p {pw} --database={db}  < xy.sql
(no answer)

$ mysql.exe -u root -p {pw} --database={db}  < xy.sql
(no answer)

$ winpty mysql.exe -u root -p {pw} --database={db}  < xy.sql
stdin is not a tty

$ winpty mysql.exe -u root -p --database={db}  < xy.sql
stdin is not a tty

$ winpty mysql.exe -u root -p
Enter password:
 
$ winpty mysql.exe -u root -p {pw}
Enter password:

$ mysql -u root -p
(no answer)

$ winpty mysql -u root -p
Enter password:

I'd be happy of workarounds and explanations, too, of course.

0

There are 0 best solutions below