MySQL5.6之后的版本在通过客户端连接或者备份时时都会有出现如下的一个警告:

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

在一些脚本操作中可能会造成一些干扰,这里介绍下两种方式来避免这个输出。

1:修改配置文件

vim /etc/mysql/my.cnf

在[client]下添加

user=***

password=***

保存退出,重启mysql进程;

此时再次连接MySQL的时候,不要在命令行出现-u -p参数,直接mysql:

root@ubuntu:/etc/mysql/mysql.conf.d# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1637
Server version: 5.7.31-0ubuntu0.16.04.1 (Ubuntu)
Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>

可以看到之前的警告就没有了!

注意:如果你是使用mysqldump指令去连接,就修改配置文件中[mysqldump]的部分。

2:重定向警告

root@ubuntu:/etc/mysql/mysql.conf.d# mysql -usaier -plr@2018 2>/dev/null
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1640
Server version: 5.7.31-0ubuntu0.16.04.1 (Ubuntu)
Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>

通过这种方式,我们把告警输出重定向到/dev/null,告警就不会输出到交互式界面了,同时脚本里也会获得一个比较纯净的返回家过变量。

这两种方式,第一种需要改配置文件,而且任何人都可以不需要密码直接进入BD,存在一定的风险性;

第二种需要重定向错误和告警输出,这样会让我们忽略掉一些异常信息,因此这两种方式需要酌情选择。

以上。

去掉Warning: Using a password on the command line interface can be insecure.相关推荐

  1. mysql备份时过滤掉某些库 以及 去掉Warning: Using a password on the command line interface can be insecure.提示信息...

    在对mysql进行完整备份时使用--all-database参数 # mysqldump -u root -h localhost -p --all-database > /root/all.s ...

  2. 已解决:mysql: [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. 解决 将密码改为后 ...

  3. 登录mysql时遇到了:mysql: [Warning] Using a password on the command line interface can be insecure.

    登录mysql时遇到了:mysql: [Warning] Using a password on the command line interface can be insecure. 问题: [ro ...

  4. mysql: “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." 解决方法 参考文 ...

  5. mysql: [Warning] Using a password on the command line interface can be insecure.解决方法

    1.在使用mysql命令的时候,出现问题: https://www.cndba.cn/hbhe0316/article/22635 https://www.cndba.cn/hbhe0316/arti ...

  6. [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. 来自TMySQL用户,包括很多开发和G ...

  7. mysql: [Warning] Using a password on the command line interface can be insecure.(using password:YES)

    前段时间不知道什么原因在Linux终端中出现无法启动Mysql的情况,在Linux终端中输入 mysql -uroot -p密码 的时候出现了下面这个错误: mysql: [Warning] Usin ...

  8. shell脚本中执行mysql 语句,去除warning using a password on the command line interface can be insecure信息...

    方法二:使用mysql参数的方法 mysql -u$user -p$pass -D $db -e "select host from user;" 当然,可以通过将传参的方式来传递 ...

  9. Warning: Using a password on the command line interface can be insecure.解决办法

    被一个小朋友问到,直接公布答案: If your MySQL client/server version is a 5.6.x a way to avoid the WARNING message a ...

最新文章

  1. vuex - 基础篇
  2. 模型预测控制c语言程序_基于数据驱动的模型预测控制
  3. 网络转型临界点 带你看瞻博网络的创新步伐
  4. 使用基于Roslyn的编译时AOP框架来解决.NET项目的代码复用问题
  5. 汇编语言复习摘要二——寄存器
  6. Java编号姓名元宝数密码,通过my Eclipse控制台向数据库(SQL2008)中查找、删除、插入信息...
  7. Java解析xml的主要解析器: SAX和DOM的选择(附上新方法--Pull解析)
  8. sql同时修改两个表的数据_如何用SQL做数据透视表?
  9. weblogic运行但局域网内无法访问控制台
  10. java exe 反编译工具_windows下java反编译工具
  11. Lingo软件的使用
  12. 操作系统实验报告(四)文件系统
  13. 威纶触摸屏如何组态设置离散量报警及报警历史记录?
  14. matlab用平方法怎么求传递闭包矩阵,逐次平方法计算传递闭包
  15. ST、SC、FC、LC光纤接头区别?
  16. 苹果手机量体温_手机记录西藏之旅和美食
  17. CDN加速全站配置教程
  18. 桌面上的文件夹怎么保存到计算机硬盘里,电脑文件怎么保存到桌面
  19. 电脑怎么翻译图片中的文字?快速翻译图片文字的方法
  20. legacy服务器安装系统,支持UEFI和LEGACY的多系统安装U盘

热门文章

  1. Sonar中如何删除一个项目
  2. 镜像驱动注入 R4900 G2 安装Esxi6.5 U1系统
  3. Web APP开发和原生app开发优势及区别
  4. 移动端css样式兼容
  5. 邮箱主机 网易 腾讯 新浪 搜狐
  6. java后端的秋招经历(含面经和答案)
  7. 【软件】实现STM32软件精确时间的方法(附源码)
  8. easyui select选择框模糊查询 以及页面引入多个版本的jquery解决办法
  9. 一文搞定MySQL聚合函数
  10. VHDL语言基础-基本语句