与任何工具一样,MySQL Shell 的开箱即用配置可能无法满足每个用户在任何情况下的需求。我们需要一种方法来轻松查看、更新和持续(如有必要)更改默认配置。有一条命令可以帮助我们管理 MySQL Shell 配置。这条命令就是 \option。
查看帮助
MySQL localhost JS > \option NAME \option - Allows working with the available shell options. SYNTAX \option [args] DESCRIPTION The given [args] define the operation to be done by this command, the following values are accepted - -h, --help [<filter>]: print help for the shell options matching filter. - -l, --list [--show-origin]: list all the shell options. - <shell_option>: print value of the shell option. - <shell_option> [=] <value> sets the value for the shell option. - --persist causes an option to be stored on the configuration file. - --unset resets an option value to the default value, removes the option from configuration file when used together with --persist option. EXAMPLES \option --persist defaultMode sql \option --unset --persist defaultMode
列出配置选项
MySQL localhost JS > \option -l autocomplete.nameCache true batchContinueOnError false connectTimeout 10 credentialStore.excludeFilters [] credentialStore.helper default credentialStore.savePasswords prompt dba.connectTimeout 5 dba.connectivityChecks true dba.gtidWaitTimeout 60 dba.logSql 0 dba.restartWaitTimeout 60 defaultCompress false defaultMode none devapi.dbObjectHandles true history.autoSave false history.maxSize 1000 history.sql.ignorePattern *IDENTIFIED*:*PASSWORD* history.sql.syslog false interactive true logFile /root/.mysqlsh/mysqlsh.log logLevel 5 logSql error logSql.ignorePattern *SELECT*:SHOW* logSql.ignorePatternUnsafe *IDENTIFIED*:*PASSWORD* mysqlPluginDir /usr/local/mysql-shell-8.0.37-linux-glibc2.28-x86-64bit/lib/mysql/plugins oci.configFile /root/.oci/config oci.profile DEFAULT outputFormat table pager "" passwordsFromStdin false resultFormat table sandboxDir /root/mysql-sandboxes showColumnTypeInfo false showWarnings true ssh.bufferSize 10240 ssh.configFile "" useWizards true verbose 0 MySQL localhost JS >
更新配置
语法格式:
\option {option name} {value} 或者 \option {option name=value}
例如,将verbose从 0 更改成 4:
MySQL localhost JS > \option verbose 0 MySQL localhost JS > \option verbose=4 MySQL localhost JS > \option verbose 4 MySQL localhost JS >
使用以上更改方式,只是对当前会话有效。
更新持久化
语法格式:
\option --persist {option name=value}
在 版本 8.4之前,mysql shell 默认是使用js模式启动;自 8.4 开始,默认是以 sql 模式开启。
MySQL localhost JS > \option defaultMode none MySQL localhost JS > \option --persist defaultMode=js MySQL localhost JS > \option defaultMode js MySQL localhost JS > \option --persist defaultMode=sql MySQL localhost JS > \option defaultMode sql MySQL localhost JS >
检查值的来源
语法格式:
\option -l --show-origin
例如:
MySQL localhost JS > \option -l --show-origin autocomplete.nameCache true (Compiled default) batchContinueOnError false (Compiled default) connectTimeout 10 (Compiled default) credentialStore.excludeFilters [] (Compiled default) credentialStore.helper default (Compiled default) credentialStore.savePasswords prompt (Compiled default) dba.connectTimeout 5 (Compiled default) dba.connectivityChecks true (Compiled default) dba.gtidWaitTimeout 60 (Compiled default) dba.logSql 0 (Compiled default) dba.restartWaitTimeout 60 (Compiled default) defaultCompress false (Compiled default) defaultMode sql (User defined) devapi.dbObjectHandles true (Compiled default) history.autoSave false (Compiled default) history.maxSize 1000 (Compiled default) history.sql.ignorePattern *IDENTIFIED*:*PASSWORD* (Compiled default) history.sql.syslog false (Compiled default) interactive true (Compiled default) logFile /root/.mysqlsh/mysqlsh.log (Compiled default) logLevel 5 (Compiled default) logSql error (Compiled default) logSql.ignorePattern *SELECT*:SHOW* (Compiled default) logSql.ignorePatternUnsafe *IDENTIFIED*:*PASSWORD* (Compiled default) mysqlPluginDir /usr/local/mysql-shell-8.0.37-linux-glibc2.28-x86-64bit/lib/mysql/plugins (Compiled default) oci.configFile /root/.oci/config (Compiled default) oci.profile DEFAULT (Compiled default) outputFormat table (Compiled default) pager "" (Compiled default) passwordsFromStdin false (Compiled default) resultFormat table (Compiled default) sandboxDir /root/mysql-sandboxes (Compiled default) showColumnTypeInfo false (Compiled default) showWarnings true (Compiled default) ssh.bufferSize 10240 (Compiled default) ssh.configFile "" (Compiled default) useWizards true (Compiled default) verbose 4 (User defined) MySQL localhost JS >
可以看到,很多值都是 Compiled default,有些是来自配置文件。
恢复模式设置
如果我们更改了配置,并希望将值恢复为默认值,我们可以使用以下语法将选项恢复为默认值。
语法格式:
\option --unset {option name} 或者 \option --unset --persist {option name}
例如:
MySQL localhost JS > \option defaultMode sql MySQL localhost JS > \option --unset --persist defaultMode MySQL localhost JS > \option defaultMode none MySQL localhost JS >标签:选项,Shell,option,default,Compiled,JS,--,MySQL From: https://www.cnblogs.com/abclife/p/18252336