Warning: Using a password on the command line interface can be insecure解決辦法


當從數據庫導出數據或mysqldump的時候,在mysql5.6.x以上版本會報Warning: Using a password on the command line interface can be insecure 錯誤,雖然不影響使用,但是還是挺煩人的。

比如在shell中執行如下導出語句

echo "select * from test limit 10 " | sh datamysql.sh > test.txt 

其中datamysql.sh文件內容如下:

mysql -h 127.0.0.1 -P xxxx -u test -pxxxx testdatabase -A

執行完之后能正常導出,但是針對這個錯誤解決辦法如下:

echo "select * from test limit 10 " | mysql --defaults-file=/path/to/config.cnf testdatabase  > test.txt 

其中config.cnf內容如下

[client]
host=127.0.0.1
user=test
password=xxxxxxx
port=xxxx

 

報上述錯誤的原因是密碼不能直接暴露在命令行中不安全

在查資料解決時,有時是 --default-extra-file 但我的使用 --defaults-file管用

更多的解決辦法見如下:

https://stackoverflow.com/questions/20751352/suppress-warning-messages-using-mysql-from-within-terminal-but-password-written

 
        

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM