1. 程式人生 > >MYSQL報警:Warning: Using a password on the command line interface can be insecure.

MYSQL報警:Warning: Using a password on the command line interface can be insecure.

color col fig文件 成功 efault 如果 輸入 nbsp pre

問題描述:執行下面的語句,sql是執行成功了,但是出現了一個報警,報警看上去始終不舒服

mysql -hip -Pport -uuser -ppassword -e "use db;delete from tb;";
Warning: Using a password on the command line interface can be insecure.

解決方法:報警的意思是“在命令行輸入密碼是不安全的”,解決方法是將用戶名和密碼寫入配置文件,然後在命令行用參數的形式引入文件

.config文件內容如下:

[mysql]
user=abc
password
=abc123
mysql --defaults-extra-file=~/.config -hip -Pport -e "use db;delete from tb;";

如果.config文件中的user、password均正確,那麽上面的sql會執行成功,並且沒有任何報警。

附:可以變動的地方及註意點

1、.config文件中的第一行除了可以是[mysql],還可以是[client]。

2、.config文件中除了password是必須的其他參數都是可選的,可以寫在配置文件中,也可以寫在命令行中。

3、--defaults-extra-file參數必須放在第一位。

4、當mysql或mysqldump使用遇到困難時,除了可以問旁邊的大神,還可以用mysql --help來幫助解決問題。

MYSQL報警:Warning: Using a password on the command line interface can be insecure.