mysqldump warning in bash script

Joined
Mar 25, 2021
Messages
28
Reaction score
0
How can I get the following script to be more secure? I am getting a mysqldump warning.

mysqldump: [Warning] Using a password on the command line interface can be insecure.

Code:
# Dump MySQL in staging area
echo "------------------------------------------------"
echo "Dumping MySQL..."
mysqldump -h "$host" -u "$username" -p"$password" "$dbName" > ~/tmp/"$projectName"/database.sql
echo "Done!"

Thanks!
 
Joined
Mar 25, 2021
Messages
28
Reaction score
0
I see. This is the source for the credentials.

Bash:
# Credentials
host=$(grep DB_HOST "config.php" |cut -d "'" -f 4)
username=$(grep DB_USER "config.php" | cut -d "'" -f 4)
password=$(grep DB_PASSWORD "config.php" | cut -d "'" -f 4)
dbName=$(grep DB_NAME "config.php" |cut -d "'" -f 4)

I am a bit new at this type of scripting. Can you elaborate on how to store the auth credentials in the .cnf file?
 

Ian

Administrator
Joined
Nov 13, 2005
Messages
80
Reaction score
20
I am a bit new at this type of scripting. Can you elaborate on how to store the auth credentials in the .cnf file?

I've not done this before myself, so I'm not sure how it's done. However, if you're pulling the credentials direct from a config.php file, then I don't think you're adding any additional layer of insecurity - so depending on the environment, you may be ok doing this.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,040
Latest member
papereejit

Latest Threads

Top