0

I'm running a shell script on a Ubuntu server, the shell script inserts data to my database (I use MariaDB) for the connection I have a database user and the database user has a password. The problem is the password is plain text, is there a way I can encrypt this password, store it in an other file, or another way so no one can read the password when reading the script?

thanks in advance,

mysql -u db_user -pplain_password <<EOF
USE db_name
INSERT INTO table ()
VALUES ();
EOF
1
  • if you can effortlessly decrypt the password, there's no real point in encrypting it. You can write the password into a file, readable by the owner only. More problematic is the fact that the password is written in the command line. No matter how strongly you encrypt the password in the file, it'll be shown in plain text just by doing a ps -ef Commented Feb 9, 2018 at 9:58

1 Answer 1

1

Check out mysql_config_editor. This will allow you to create a .mylogin.cnf file which will store the password in an encrypted form. .mylogin.cnf will be used by your script, or other client program, to connect to the database.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.