最近在部署Zabbix时需要用脚本取得一些MySQL的返回参数,需要是numberic格式的,但是调用脚本时总是输出这一句:

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

grep -v也是处理不掉的,很是烦人,在网上翻了翻解决掉,记录于此:

Mysql命令有个如下参数:

--defaults-extra-file=# Read this file after the global files are read.

因此编辑一个password.txt的文件:

[client]
user=leo
password=leo

脚本中的MySQL连接使用mysql --defaults-extra-file=password.txt的格式,这样就不会报insecure的报错啦。

后来查看mysql命令行的manual,发现个更简洁的办法:

因为mysql命令读取配置文件的顺序为/etc/my.cnf /etc/mysql/my.cnf /usr/etc/my.cnf ~/.my.cnf,所以可以将账号密码写入~/.my.cnf中,这样执行时只需要指定-u参数即可,注意此文件权限建议设置为600。

# ~/.my.cnf示例:
[client]
user=root
password=<你的密码>
# 上述的[client]也可以替换为[mysql]

注意:

这个报错是和mysql client相关的,如果你使用低版本的mysql客户端,那么就不会报错。例如你使用mysql-5.1.73-5.el6_6.x86_64包安装的/usr/bin/mysql就不会产生这个warning,使用MySQL5.7或者8.0的mysql命令就会有此报错。

消除Warning: Using a password on the command line interface can be insecure的提示的更多相关文章

  1. MySQL 5.6 Warning: Using a password on the command line interface can be insecure

    MySQL 5.6 在命令行输入密码,就会提示这些安全警告信息. Warning: Using a password on the command line interface can be inse ...

  2. Centos下_MysqL5.7在使用mysqldump命令备份数据库报错:mysqldump: [Warning] Using a password on the command line interface can be insecure.

    在阿里云服务器增加一个shell脚本定时备份数据库脚本执行任务时,测试性的执行了备份命令,如下 [root@iZ2ze503xw2q1fftv5rhboZ mysql_bak]# /usr/local ...

  3. Warning: Using a password on the command line interface can be insecure.

    [root@qttc ~]# /usr/local/mysql/bin/mysqldump  -uroot -proot db > bak.sqlWarning: Using a passwor ...

  4. mysql 备份报错mysqldump: [Warning] Using a password on the command line interface can be insecure.

    -------------------------------------------------------------------------------- mysql 备份报错mysqldump ...

  5. MYSQL5.7脚本运行时出现[Warning] Using a password on the command line interface can be insecure

    MYSQL版本:5.7 在写linux脚本执行MYSQL命令的时候,如果使用 MYSQL="mysql -hlocalhost -P3306 -uroot -p666666" 登陆 ...

  6. 数据库备份出现警告:Warning: Using a password on the command line interface can be insecure. Warning: A partial dump from a server that has GTIDs will by default include the GTIDs of all transactions, even thos

    1.先来看原备份数据库语句: mysqldump -h 127.0.0.1 -uroot -ppassword database > /usr/microStorage/dbbackup/cap ...

  7. zabbix 3.4监控mysql,提示mysql: [Warning] Using a password on the command line interface can be insecure.

    mysql从5.6版本开始,如果是命令行直接出现了数据库连接密码就会有以下警告: mysql: [Warning] Using a password on the command line inter ...

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

    问题描述:执行下面的语句,sql是执行成功了,但是出现了一个报警,报警看上去始终不舒服 mysql -hip -Pport -uuser -ppassword -e "use db;dele ...

  9. 解决mysql连接输入密码提示Warning: Using a password on the command line interface can be insecure

    有时候客户端连接mysql需要指定密码时(如用zabbix监控mysql)5.6后数据库会给出个警告信息 mysql -uroot -pxxxx Warning: Using a password o ...

随机推荐

  1. HttpServetRequest读取body只能一次的问题

    HTTP请求中的是字符串数据: //字符串读取 void charReader(HttpServletRequest request) { BufferedReader br = request.ge ...

  2. centos7下安装samba服务器

    samba笔记: http://services.linuxpanda.tech/%E7%BD%91%E7%BB%9C%E6%96%87%E4%BB%B6%E5%85%B1%E4%BA%AB/samb ...

  3. kubelet集群网络配置flannel(覆盖网络)

    kubernetes本身并不会对跨主机容器的网络进行设置,这需要额外的工具来实现.一些常用的开源工具主要包括flanne.OpenvSwitch.Weave.Calico等,这里面最常用的是flann ...

  4. Perl的命令行参数和ARGV

    程序名:$0 $0表示当前正在运行的Perl脚本名.有3种情况: 如果执行方式为perl x.pl,则$0的值为x.pl而非perl命令本身 如果执行方式为./x.pl,则$0的值为./x.pl 如果 ...

  5. python语法风格

    这里只给出其它文章里不适合出现部分语法风格. python有几种类型的复合语句:if.for.while.def.class.try/except.with/as等.这些复合类型的语句在编写时,要遵循 ...

  6. [转]Docker基础-使用Dockerfile创建镜像

    本文转自:https://www.cnblogs.com/jie-fang/p/7927643.html 1.基本结构 Dockerfile由一行行命令语句组成,并支持以#开头的注释行.例如: # T ...

  7. IIS域名转发

    在IIS中设置Http重定向 界面操作如下: 最终通过上面的操作生成了一个配置文件如下: 我这面就是一个空的目录,里面仅包含这个配置文件,就可以实现转发啦

  8. 从零开始学安全(二十五)●用nmap做端口扫描

    以上是常用的端口扫描 -T 用法 每个级别发包时间  当没有使用T 时默认的使用T3级别发包 半开扫描  先探测主机是否存活 再用-sS  扫描端口   容易造成syn 包攻击 就是利用僵尸主机  进 ...

  9. 【Java每日一题】20170220

    20170217问题解析请点击今日问题下方的“[Java每日一题]20170220”查看(问题解析在公众号首发,公众号ID:weknow619) package Feb2017; import jav ...

  10. oracle中rownum的使用

    rownum是系统的一个关键字,表示行号,是系统自动分配的,第一条符合要求的数据行号就是1,第二条符合要求的数据行号就是2. Rownum 不能直接使用 例:取前多少条数据: 取中间的一些数据: se ...