MySQL5.7.27报错“[Warning] Using a password on the command line interface can be insecure.”在命令行使用密码不安全警告

原因

这个错误是在我执行备份脚本的时候出现的

# mysqldump -h主机名 -u用户名 -p密码 数据库名称 > /usr/local/dbbackup/数据库名称_$(date +%Y%m%d_%H%M%S).sql

原因是mysql的安全机制导致,因为在命令行直接将命令写上,被认为是不安全的行为

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

虽然会报错,但是并不影响是数据库的备份

解决方法

方法一:修改my.cnf配置文件

编辑/etc/my.cnf配置文件

[root@localhost local]# vi /etc/my.cnf

在配置文件中添加如下内容

[client]
port =
socket = /tmp/mysql.sock
default-character-set = utf8mb4
host = 主机ip        
user = 数据库用户名
password = '数据库密码'  

使用命令导入导出(指定加载配置文件)

#导出数据库
mysqldump --defaults-extra-file=/etc/my.cnf 数据库名称 > 数据库名称_$(date +%Y%m%d_%H%M%S).sql
#导入数据库
mysql --defaults-extra-file=/etc/my.cnf 数据库名称 < 数据库名称_$(date +%Y%m%d_%H%M%S).sql

方法二:直接在linux环境中添加mysql环境

编辑/etc/profile配置文件

[root@localhost local]# vi /etc/profile

在最后面添加如下内容,保存并退出

export MYSQL_PWD=数据库密码

使配置生效

[root@localhost local]# source /etc/profile

使用mysqldump命令备份数据库的时候就可以省略-p密码参数,执行脚本就不会报错了

# mysqldump -h主机名 -u用户名  数据库名称 > /usr/local/dbbackup/数据库名称_$(date +%Y%m%d_%H%M%S).sql

【mysql报错】MySQL5.7.27报错“[Warning] Using a password on the command line interface can be insecure.”的更多相关文章

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

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

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

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

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

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

  4. 解决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 ...

  5. 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 ...

  6. 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 ...

  7. 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" 登陆 ...

  8. 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 ...

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

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

随机推荐

  1. 15-scrapy-redis两种形式分布式爬虫

    什么叫做分布式爬虫? 分布式爬虫,就是多台机器共用一个scrapy—redis程序高效爬取数据, 为啥要用分布式爬虫? 其一:因为多台机器上部署的scrapy会各自拥有各自的调度器,这样就使得多台机器 ...

  2. 支付签名 MD5Util 排序工具类

    package com.skynet.wechat.wxPay.common; import java.security.MessageDigest; import java.util.Iterato ...

  3. attention 汇总(持续)

    Seq2seq Attention Normal Attention 1.  在decoder端,encoder state要进行一个线性变换,得到r1,可以用全连接,可以用conv,取决于自己,这里 ...

  4. WPF后台代码实现TextBlock滚动条

    方法一: 常规的WPF操作: <ScrollViewer Width=" VerticalScrollBarVisibility="Auto" Horizontal ...

  5. Hive表导出成csv文件

    命令 hive -e " set hive.cli.print.header=true; #将表头输出 select * from data_table where some_query_c ...

  6. Java生鲜电商平台-电商订单系统全解析

    Java生鲜电商平台-电商订单系统全解析 说明:Java生鲜电商平台-电商订单系统全解析主要讲解OMS的内容,设计,开发,架构等知识. 今天分享将会分为以下三个环节来阐述: 1.订单系统的介绍 2.订 ...

  7. idea的service注入mapper报错

    一.问题 idea的java项目中,service类中注入mapper报错 二.解决 方法1 在mapper类上加上  @Repository 注解即可,当然不加也行,程序也不回报错,是idea的误报 ...

  8. 车联网APP,安全设施薄弱的山寨品

    - HDIT 来到该公司官网,打开任意一个云平台的链接,很显眼地能看见APP的下载按钮,下载,安装,抓包,使用,完全的套路,熟门熟路是不是. 再看抓取的报文,满目的HTTP协议数据: 完全没有对APP ...

  9. Android 遍历手机应用,跳转应用市场详情页面

    首先遍历手机内应用,找到需要的应用包名: /** * 遍历手机内应用包名 * @param context */ public static void loadApps(Context context ...

  10. 026.[转] 基于Docker及Kubernetes技术构建容器云平台 (PaaS)

    [编者的话] 目前很多的容器云平台通过Docker及Kubernetes等技术提供应用运行平台,从而实现运维自动化,快速部署应用.弹性伸缩和动态调整应用环境资源,提高研发运营效率. 本文简要介绍了与容 ...