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. IT兄弟连 HTML5教程 HTML5和JavaScript的关系

    JavaScript可是实现HTML5重要语言.长久以来,JavaScript一直都是在HTML中实现动态效果的不二之选,而JavaScript在一些程序员眼里都是编程语言中的二等公民.早先,它经常是 ...

  2. 基于python的selenium常用操作方法(1)

    1 selenium定位方法    Selenium提供了8种定位方式. ·         id ·         name ·         class name ·         tag ...

  3. json递归查询

    主体: class json_search(): '''递归查询依赖key''' def search_key(self,data,key): self.data = data self.key_va ...

  4. MongoDB for OPS 02:复制集 RS 配置

    写在前面的话 对于生产环境而言,除非是非常不重要的业务,且该业务允许我们出现一定时间的停机,我们一般才会使用单节点,且该单节点必须要有完善的备份手段. RS 复制集 我们这里采取一主两从的方式搭建复制 ...

  5. SmtpClient发送邮件时附件名称乱码

    在用户环境发现一个现象,使用System.Net.Mail.SmtpClient发送邮件,当附件名包含中文且长度较长时,最终的邮件里附件名会乱掉,写个简单的测试程序: var mail = new M ...

  6. AwaitAsync(异步和多线程)

    参考了一些大佬写的文章: https://www.cnblogs.com/yilezhu/p/10555849.html这个大佬写的文章,我还是很喜欢的 https://www.cnblogs.com ...

  7. C++ 流插入"<<"和流提取">>"运算符的重载

    01 流插入<<运算符的重载 C++ 在输出内容时,最常用的方式: std::cout << 1 <<"hello"; 问题: 那这条语句为什么 ...

  8. IDEA创建maven web工程

    一.新建一个maven web工程 step1 File --> New --> Project step2 按下图步骤操作 step3 填写项目信息 step4 选择本地的maven安装 ...

  9. Vue常用语法

    一.模板语法 1.双大括号表达式 [语法:] {{exp}} 用于向页面输入数据,即页面显示数据. [举例:] <!doctype html> <html lang="en ...

  10. 解决sublime快捷键回车换行问题

    鼠标右键sublime 以管理员身份运行 打开首选项里面的按键绑定用户 将下面的代码粘贴复制 { "keys": ["enter"], "comman ...