Store MySQL password in bash - script

You need to create a simple backup mysql script.

But how can I store the encrypted MySQL user pass in it?

I want to avoid saving the password as plain text in any additional files.

As I found in the MySQL manual:

MySQL encrypts passwords stored in a user table using its own algorithm

So. no way to just get hashand set it as a variable?

I mean:

DBHASH="cGFzc3dvcmQ="
DBPASS=`echo $DBHASH | openssl enc -base64 -d`

Is there a proper way to connect it? Thanks for the tips.

+4
source share
2 answers

, script , MySQL ( ) - . / MySQL, ( ).

, : . ...

  • chmoded (600) ~/.my.cnf .
  • , .
  • localhost/backup .
  • Debian, debian-sys-maint ( my.cnf )
  • mysql script, / script ( root, mysql ).
  • /'source' ( /) ( chmod - 600)... my.cnf- .

, " " ..

+7

afaict, , . , , , - script.

, , mysql, script. , , exec script.

+2

All Articles