0

I am currently running mysql through bash. However it returns the error:

Using a password on the command line interface can be insecure. 

What are the secure ways to accomplish this? How can I properly call the mysql without this warning?

#!/bin/bash/ user=test password=test database=test mysql --user='$user' --password='$password' --database='$database' --execute='DROP DATABASE $user; CREATE DATABASE $database;' 

Result

Warning: Using a password on the command line interface can be insecure. 
13
  • Where do you use the ffmpeg_path variable? Commented May 28, 2015 at 21:10
  • I don't think the error has anything to do with the user of the variable. Commented May 28, 2015 at 21:11
  • @Barmar Thanks, I made the necessary changes. Commented May 28, 2015 at 21:11
  • Does the warning go away if you use <(/home/yourusername/bin/ffprobe -i "$file" -show_format -v quiet | grep '.=.')? Commented May 28, 2015 at 21:12
  • @Barmar, I tried that and it still gives the same error. Commented May 28, 2015 at 21:13

2 Answers 2

2

You command opens a mysql session passing as argument the mysql password (I see this message tenths at day).

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

1 Comment

Oh yes, this was also an issue. It was below a few lines below the script shown above.
1

Instead of putting the password on the command line, create a ~/.my.cnf file, and put the password in there. The file can supply default values for any of the command line options. For instance, you can put this in it:

[client] database = test user = test password = test 

Then you can just run:

mysql --execute='DROP DATABASE $user; CREATE DATABASE $database;' 

Make sure the file's permissions are restricted, so unauthorized users can't see the password.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.