[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
意思就是說,密碼露了,不安全。

執行腳本的時候,最好可以把這個東西干掉,否則一直彈

解決:
1. 在任意地方新建一個文件,存放用戶名、密碼
vim /etc/my.password
[client]
user=root
password=密碼
 

2. 登錄時不用-u -p來指定,使用--defaults-extra-file=/etc/my.password來指定配置文件進行登錄即可消掉warning提示
mysql --defaults-extra-file=/etc/my.password


導入數據示例:
[root@db mysql_data]# ll *.sql
-rw-r--r--. 1 root root        15903 Feb 19 05:52 app1-20220218.sql
-rw-r--r--. 1 root root       725807 Feb 19 05:52 app2-20220218.sql
-rw-r--r--. 1 root root       245766 Feb 19 05:52 app3-20220218.sql
-rw-r--r--. 1 root root        19971 Feb 19 04:02 canager-20220218.sql
-rw-r--r--. 1 root root       213869 Feb 19 04:02 dateb-20220218.sql
-rw-r--r--. 1 root root   7629149071 Feb 19 04:05 db1-20220218.sql
-rw-r--r--. 1 root root   5177801470 Feb 19 04:39 gzs-20220218.sql
-rw-r--r--. 1 root root  19271126413 Feb 19 04:15 shegu-20220218.sql
-rw-r--r--. 1 root root          950 Feb 19 04:37 voluk-20220218.sql
-rw-r--r--. 1 root root  52776440548 Feb 19 04:36 voluic_temp-20220218.sql
-rw-r--r--. 1 root root        31384 Feb 19 05:52 ytk-20220218.sql
-rw-r--r--. 1 root root        10648 Feb 19 05:52 yko_job-20220218.sql
-rw-r--r--. 1 root root 110680794125 Feb 19 05:52 zyjm-20220218.sql
-rw-r--r--. 1 root root     38677534 Feb 19 04:37 zgip-20220218.sql


[root@db mysql_data]# pwd
/data/mysql_data
[root@db mysql_data]# mkdir tmp && cd tmp

[root@db tmp]# vim my.password 
[client]
host=192.168.1.30
user=root
password=<Password>


[root@db tmp]# vim daoru.sh 
#!/bin/bash
for i in `ls /data/mysql_data/*.sql`;do
    mysql --defaults-extra-file=/data/mysql_data/tmp/my.password -e "source $i"
done


# 運行(開始導入數據)
[root@db tmp]# nohup bash daoru.sh 2>&1 &

.
.
.
.
游走在各發行版間老司機QQ群:905201396
不要嫌啰嗦的新手QQ群:756805267
Debian適應QQ群:912567610


免責聲明!

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



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