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