[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

posted @   Linux大魔王  阅读(13797)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
点击右上角即可分享
微信分享提示