my_print_defaults 及perror

参考文档:
https://mysql.net.cn/doc/refman/8.0/en/my-print-defaults.html
https://mysql.net.cn/doc/refman/8.0/en/perror.html

-- my.cnf的内容

[root@redhat762100 mysql3306]# more my.cnf
[mysqld]
datadir=/mysql/mysql3306/data
#socket=/tmp/mysql3306.sock
socket=/mysql/mysql3306.sock
port=3306
basedir=/mysql/mysql3306
slow_query_log=1
slow_query_log_file=/mysql/mysql3306/data/slow.log
log-error=/mysql/mysql3306/data/error.log
long_query_time=0.5
server-id=3306
# Disabling symbolic-links is recommended to prevent assorted security risks
log-bin=mysql3306-bin
character_set_server=utf8
binlog_format=row
gtid_mode=on
log_slave_updates=1
enforce_gtid_consistency=1
relay-log-index=slave-relay-bin.index
relay-log=slave-relay-bin
relay_log_recovery=1

rpl_semi_sync_master_enabled=ON
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

innodb_buffer_pool_dump_at_shutdown=1
innodb_buffer_pool_load_at_startup=1
#innodb_buffer_pool_dump_now=1
#innodb_buffer_pool_load_now=1

#add 20230928 for mysqldump
secure_file_priv=
[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

[client]
port=3306
socket=/mysql/mysql3306.sock
#default-character-set=utf8
[mysql]
prompt="\u@db \R:\m:\s [\d]> "
[root@redhat762100 mysql3306]#

-- 打印出mysqld和mysql的内容

[root@redhat762100 mysql3306]# my_print_defaults  mysqld mysql
--datadir=/mysql/mysql3306/data
--socket=/mysql/mysql3306.sock
--port=3306
--basedir=/mysql/mysql3306
--slow_query_log=1
--slow_query_log_file=/mysql/mysql3306/data/slow.log
--log-error=/mysql/mysql3306/data/error.log
--long_query_time=0.5
--server-id=3306
--log-bin=mysql3306-bin
--character_set_server=utf8
--binlog_format=row
--gtid_mode=on
--log_slave_updates=1
--enforce_gtid_consistency=1
--relay-log-index=slave-relay-bin.index
--relay-log=slave-relay-bin
--relay_log_recovery=1
--rpl_semi_sync_master_enabled=ON
--symbolic-links=0
--innodb_buffer_pool_dump_at_shutdown=1
--innodb_buffer_pool_load_at_startup=1
--secure_file_priv=
--prompt=\u@db \R:\m:  [\d]>
[root@redhat762100 mysql3306]#

-- 打印出mysql和client的内容

[root@redhat762100 mysql3306]# my_print_defaults  client mysql
--port=3306
--socket=/mysql/mysql3306.sock
--prompt=\u@db \R:\m:  [\d]>
[root@redhat762100 mysql3306]#

-- 打印出mysqld_safe的内容,因为my.cnf里面没有的,所以打印出为空

[root@redhat762100 mysql3306]# my_print_defaults  mysqld_safe
[root@redhat762100 mysql3306]#

--打印出指定的配置文件中的内容 

[root@redhat762100 mysql3306]# my_print_defaults  --defaults-file=/etc/my.cnf  mysqld3307
--socket=/mysql/mysql3307.sock
--port=3307
--pid-file=/mysql/mysql3307/data/redhat762100.pid
--datadir=/mysql/mysql3307/data
--language=/mysql/mysql3307/share/english
--user=root
--basedir=/mysql/mysql3307
--slow_query_log=1
--slow_query_log_file=/mysql/mysql3307/data/slow.log
--log-error=/mysql/mysql3307/data/error.log
--long_query_time=0.5
--server-id=3307
--log-bin=mysql3307-bin
--character_set_server=utf8
--binlog_format=row
--gtid_mode=on
--log_slave_updates=1
--enforce_gtid_consistency=1
--relay-log-index=slave-relay-bin.index
--relay-log=slave-relay-bin
--relay_log_recovery=1
--rpl_semi_sync_master_enabled=ON
--symbolic-links=0
--relay_log_recovery=on
--innodb_buffer_pool_dump_at_shutdown=1
--innodb_buffer_pool_load_at_startup=1
--replicate-wild-ignore-table=test.t1
--secure_file_priv=
[root@redhat762100 mysql3306]#

-- 查看密码

[root@redhat762100 mysql3306]# my_print_defaults  -s 3306
--user=root
--password=mysql
--host=127.0.0.1
--port=3306
[root@redhat762100 mysql3306]# my_print_defaults   3306
--user=root
--password=*****
--host=127.0.0.1
--port=3306
[root@redhat762100 mysql3306]

--perror 

[root@redhat762100 mysql3306]# perror 1231
MySQL error code 1231 (ER_WRONG_VALUE_FOR_VAR): Variable '%-.64s' can't be set to the value of '%-.200s'
[root@redhat762100 mysql3306]#

END 

你可能感兴趣的:(MySQL,mysql)