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' -

Making Empty C++ Project: General exception (Exception from HRESULT:0x80131500) Visual Studio Community 2015 -

How to fix java warning for "The value of the local variable is not used " -