您好,我有一个脚本可以对一些 mysql 数据库进行分区。我们正在从 5.5 升级到 5.6。在测试脚本时,我注意到新的 5.6 版本的 mysql 返回 Warning: Using a password on the command line interface can be insecure.
解决此问题的最佳方法是什么?我读到一个解决方法是 2>/dev/null
但我将无法获得退出代码或任何错误,如果它们发生的话。有没有其他方法可以做到这一点。这是有问题的代码行:
MYSQL_RESULT=`echo "SET sql_log_bin=0;SET @pdb='$DB',@ptable='$table';CALL maintenance(@pdb,@ptable);SET sql_log_bin=1;"|mysql -uUSER -pPASSWORD database`
最佳答案
解决此问题的一种方法是在 ~/.my.cnf
文件中设置适当的变量。与此类似的内容应该有所帮助:
[mysql]
user=my_username
password=my_password
这应该位于执行命令的用户的主目录中。并且不要忘记为该文件设置正确的权限以避免它被其他用户读取:chmod 600 ~/.my.cnf
。
关于mysql - Bash 脚本 Mysql 警告 : Using a password on the command line interface can be insecure,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23762575/