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. 避免python二维列表append一维列表时浅拷贝问题

    原始问题: 由于浅拷贝原因,使得当a列表变动时,b列表也发生变动 解决办法: 如上图所示,添加的时候添加新列即可,类似新建一个列表,使得与原有列表a不共用同一个内存

  2. 世界GDP数据可视化

    各国GDP数据可视化 数据来自世界银行 导入资源包,如下: Pandas, numpy, seaborn 和 matplotlib import pandas as pd import numpy a ...

  3. 给HttpClient添加请求头(HttpClientFactory)

    前言 在微服务的大环境下,会出现这个服务调用这个接口,那个接口的情况.假设出了问题,需要排查的时候,我们要怎么关联不同服务之间的调用情况呢?换句话就是说,这个请求的结果不对,看看是那里出了问题. 最简 ...

  4. 定位表和索引使用的Page

    数据存储的基本单元是Page,每个Page是8KB,数据文件(mdf和ndf)占用的硬盘空间,逻辑上按照PageNumber进行划分,也就是说,可以把数据文件看作是PageNumber 从0到n的连续 ...

  5. nginx: [emerg] unknown directive “ ” in /usr/local/nginx/nginx.conf.conf:xx报错处理

    当我们在修改Nginx的配置文件,然后加载配置文件./nginx -s reload   报错类似的错误, nginx: [emerg] unknown directive “ ” in /usr/l ...

  6. wpf 单例模式和异常处理 (原发布 csdn 2017-04-12 20:34:12)

    第一次写博客,如有错误,请大家及时告知,本人立即改之. 如果您有好的想法或者建议,我随时与我联系. 如果发现代码有误导时,请与我联系,我立即改之. 好了不多说,直接贴代码. 一般的错误,使用下面三个就 ...

  7. 1.springMVC Controller配置方式

    一.手动配置方式 1.web.xml中DispatcherServlet控制器的的配置 SpringMVC也是一种基于请求驱动的WEB框架,并且使用了前端控制器的设计模式.前端控制器就是Dispatc ...

  8. MySQL入门——在Linux下安装和卸载MySQL

    MySQL入门——在Linux下安装和卸载MySQL 摘要:本文主要学习了如何在Linux系统中安装和卸载MySQL数据库. 查看有没有安装过MySQL 使用命令查看有没有安装过: [root@loc ...

  9. LeetCode题解002:两数相加

    两数相加 题目 给出两个 非空 的链表用来表示两个非负的整数.其中,它们各自的位数是按照 逆序 的方式存储的,并且它们的每个节点只能存储 一位 数字 如果,我们将这两个数相加起来,则会返回一个新的链表 ...

  10. javascript json的使用

    转自:http://blog.csdn.net/lushuaiyin/article/details/7061483 对于js使用json,首先到官网拷贝json.js文件,地址http://www. ...