最近在部署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. SpringCloud2.0入门3-新的eureka依赖

    前言 Springboot2.0推出有一段时间了,是要学习1.5+还是从2.0开始?犹豫的原因是资料不全,目前现有的资料大部分是1.0的.但作为学习者,肯定要学习最新的.不如,先试试. 搭建Eurek ...

  2. linux 命令 — download

    wget 下载工具 一般 wget url 下载url指定的资源,日志输出到stdout,文件名称和url中指定的资源名称一致 wget url -o log -O file -o:指定日志输出到的文 ...

  3. Django 系列博客(三)

    Django 系列博客(三) 前言 本篇博客介绍 django 的前后端交互及如何处理 get 请求和 post 请求. get 请求 get请求是单纯的请求一个页面资源,一般不建议进行账号信息的传输 ...

  4. springMVC中的注解@RequestParam与@PathVariable的区别

    1.@PathVariable @PathVariable绑定URI模板变量值 @PathVariable是用来获得请求url中的动态参数的 @PathVariable用于将请求URL中的模板变量映射 ...

  5. mybatis逆向工程(MyBatis Generator)

    mybatis逆向工程(MyBatis Generator) 1. 什么是mybatis逆向工程 mybatis官方为了提高开发效率,提高自动对单表生成sql,包括 :mapper.xml.mappe ...

  6. 第一册:lesson thirty five。

    原文: Our village . This is a photograph of our village. Our village is in  a valley. It is between to ...

  7. c#基础学习(0625)之vs常用快捷键、基础数据类型、命名规范

    vs常用快捷键 Ctrl+K+D:快速对齐代码 Ctrl+z:撤销 Ctrl+S:保存 Ctrl+J:快速弹出只能提示 Shift+End:从行首快速选中整行 Shift+Home:从行未快速选中整行 ...

  8. JPA、Hibernate、Spring data jpa之间的关系,终于明白了

    什么么是JPA? 全称Java Persistence API,可以通过注解或者XML描述[对象-关系表]之间的映射关系,并将实体对象持久化到数据库中. 为我们提供了: 1)ORM映射元数据:JPA支 ...

  9. python之strip()小记

    描述 Python strip() 方法用于移除字符串头尾指定的字符(默认为空格或换行符)或字符序列. 注意:该方法只能删除开头或是结尾的字符,不能删除中间部分的字符. 语法 strip()方法语法: ...

  10. [android] 利用广播实现ip拨号

    广播接收者,broadcast receiver,安卓系统在使用时会产生很多的事件,比如:短信到来,电量低,拨打电话等等 界面布局,线性布局,EditText指定为电话号码,设置属性android:i ...