|
使用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]#
|
|