重庆思庄Oracle、Redhat认证学习论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1025|回复: 0
打印 上一主题 下一主题

[命令及语法] 处理mysqldump导出提示:[Warning] Using a password on the command line

[复制链接]
跳转到指定楼层
楼主
发表于 2022-10-24 17:16:12 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
使用mysql备份数据库时,报[Warning] Using a password on the command line interface can be insecure.错误
[root@sztech ~]# mysqldump -uroot -pWangjia wangjia > /opt/test01.sql
mysqldump: [Warning] Using a password on the command line interface can be insecure.

解决办法:
修改配置文件:    vim etc/my.cnf
    在最底部加入以下内容,如果加在配置文件中间,可能会报错:
    user=root

  password="mysql数据库的密码"

[root@sztech etc]# cat my.cnf
#[mysqld]
#datadir=/var/lib/mysql
#socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
#symbolic-links=0
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd

#[mysqld_safe]
#log-error=/var/log/mariadb/mariadb.log
#pid-file=/var/run/mariadb/mariadb.pid

#
# include all files from the config directory
#
!includedir /etc/my.cnf.d


[mysqld]
    basedir = /usr/local/mysql   
    datadir = /usr/local/mysql/data
    socket = /usr/local/mysql/mysql.sock
    character-set-server=utf8
    port = 3306
   sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
[client]
   socket = /usr/local/mysql/mysql.sock
   default-character-set=utf8
   user=root
   password=Wangjia


[root@sztech etc]#

验证:
通过修改该配置之后:
    mysqldump 后边可以不输入 用户  密码,直接 执行备份指令,格式如下:
      mysqldump 库名 表名 > /opt/自定义命名.sql


[root@sztech ~]#  mysqldump wangjia > /opt/test01.sql
[root@sztech ~]#

[root@sztech opt]# ll
total 2752
-rw-r--r--. 1 root root  229376 Oct 24 15:55 mysql-2022-10-24.tar
-rw-r--r--. 1 root root 2578748 Oct 24 15:50 mysql-2022-10-24.tar.xz
drwxr-xr-x. 2 root root       6 Oct 31  2018 rh
-rw-r--r--. 1 root root    1906 Oct 24 17:10 test01.sql
-rw-r--r--. 1 root root    1906 Oct 24 16:48 test.sql
[root@sztech opt]#




分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 支持支持 反对反对
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|手机版|小黑屋|重庆思庄Oracle、Redhat认证学习论坛 ( 渝ICP备12004239号-4 )

GMT+8, 2024-4-28 20:15 , Processed in 0.089453 second(s), 20 queries .

重庆思庄学习中心论坛-重庆思庄科技有限公司论坛

© 2001-2020

快速回复 返回顶部 返回列表