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

android - Why am I getting the message 'Youractivity.java is not an activity subclass or alias' -

python - How do I create a list index that loops through integers in another list -

c# - “System.Security.Cryptography.CryptographicException: Keyset does not exist” when reading private key from remote machine -