最近在部署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. [转]php中 curl模拟post发送json并接收json

    本文转自:https://blog.csdn.net/pangchengyong0724/article/details/52103962 本地模拟请求服务器数据,请求数据格式为json,服务器返回数 ...

  2. Linux下尝鲜IDE Rider .NET又一开发利器

    RiderRS 扯淡:很多人说:jetbrains出品,必属精品,jetbrains确实出了不少好东西,但是他的产品总感觉越用越慢,我的小Y430P高配版也倍感压力,内存占用率高. Multiple ...

  3. 在Prism 框架中,实现主程序与模块间 UI 的通信

    背景: 在模块的UI中包含 TreeView 控件,在该树形控件的每一节点前面定义了一个复选框,如图 需求: 在两个不同的应用程序中使用该控件,而它在不同应用程序中的外观则并不一致,按照本例,即一个显 ...

  4. Maven(七)Eclipse使用Maven命令

    由于没有mvn compile (其余命令类似) 可以点解上面框中选项手动输入compile

  5. Java基础IO流(五)RandomAccessFile

    RandomAccessFile java提供的对文件内容的访问,既可以读文件也可以写文件.RandomAccessFile支持随机访问文件,可以访问文件的任意位置 (1)java文件模型:    在 ...

  6. js高级:event,事件冒泡,事件捕获

    1.事件 浏览器客户端上客户触发的行为都称为事件 所有的事件都是天生自带的,不需要我们去绑定,只需要我们去触发. 通过 obj.事件名=function(){} 事件名:onmouseover 鼠标悬 ...

  7. JavaAndroid项目结构

    使用Java的Android项目的结构 src: 源码文件夹 gen: 自动生成的源码文件夹 assets: 资产目录 bin: 编译生成的文件目录(apk等) libs: jar包 res: 资源文 ...

  8. SQLite: sql script demo

    如果有成熟的架构,如何根据数据库关系的表.视图等,进行代码生成架构?减少写代码的时间? -- 考虑主键外键 -- create database geovindu; use geovindu; --2 ...

  9. vue从入门到进阶:简介(一)

    前言 用了这么久的vue了,但是一直没有时间写个系列文章,现在抽一定时间总结下vue的知识点. 首先,Vue 不支持 IE8 及以下版本,因为 Vue 使用了 IE8 无法模拟的 ECMAScript ...

  10. VS2017 docker部署工具的使用

    **简要描述:** - VS2017的docker支持工具,支持对.Net Framework,.Net Core控制台或者Web应用,在docker中生成,调试,运行.对于.Net Framewor ...