shell - How to pass password from file to mysql command? -


i have shell script calls mysql command 1 parameter external file, looks (also saw example in other resources):

mysql --user=root --password=`cat /root/.mysql` 

bit not working:

failed connect mysql server: access denied user 'root'@'localhost' (using password: yes).

i tried different quotes without success. how pass it?

update 1: found can pass password without space symbol. problem in this, root pass contains spaces.

finally line working:

 mysql --user=root --password="$(cat /root/.mysql)" 

or:

mysql --user=root --password="$(< /root/.mysql)" 

root password must without quotes: bla bla bla

if password not contains spaces can use:

mysql --user=root --password=`cat /root/.mysql` 

Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -