We usually use MySQL login information on shell scripts to load some data into database or to fetch some monitoring information. To login to the database will write login information on Shell Scripts as below
#!/bin/sh username = someusername password = somepassword $ mysql -u$username -p$password -A -v -SBy doing that so, we will hit a warning in stdout saying:
Warning: Using a password on the command line interface can be insecureTo avoid the warning in shell script, we need to so some workaround like below:
1. Create a hidden file configuration file
> touch /tmp/.mysqllogin.cnf2. Enter your database credential information on the hidden file:
> vi /tmp/.mysqllogin.cnf [client] user=someusername password=somepassword3. Save the file and try to login to mysql using --defaults-extra-file keyword like
$ mysql --defaults-extra-file=/tmp/.mysqllogin.cnf -A -vBy using this workaround you can avoid the warning.
Comments
Post a Comment