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

我的操作系统是windows10。

MySQL数据库的导出和访问的时候采用mysqldump命令,出现如下错误提示:
“Warning: Using a password on the command line interface can be insecure.”

这个问题应该是在MySQL5.6+版本的时候就有出现,可能是为了确保数据库的安全性采用的保护机制。

我们需要修改或新建数据库配置文件,在安装目录的bin目录下,新建文件my.cnf,给[client]选项增加三行命令文件内容如下:

[client]
port = 3306
socket = /tmp/mysql.sock
default-character-set = utf8mb4
host = localhost
user = root
password = '123456'

注意用户名、密码一定要对应。

我习惯性的重启了mysql服务,再同样执行备份命令,发现还是出现同样的错误。

切换到安装目录的bin目录。

C:\Windows\system32>d:

D:\>cd mysql-8.0.21-winx64\mysql-8.0.21-winx64\bin

命令和以前常用的快速导入和导入命令有所不同了,需要加载我们配置的MYSQL配置文件!更改命令为:

mysqldump --defaults-extra-file=my.cnf db table1 table2>d:\tabbak.sql

成功!

posted @ 2020-09-18 22:44  超越吧  阅读(708)  评论(0编辑  收藏  举报