首页 > 数据库 >管理 MySQL Shell 配置选项

管理 MySQL Shell 配置选项

时间:2024-06-20 13:31:53浏览次数:15  
标签:选项 Shell option default Compiled JS -- MySQL

与任何工具一样,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

相关文章

  • shell运算符
    熟练掌握以上运算符能够自如的应对linux日常shell脚本需求。数值运算符只能用在数字上,不能用在其它数据类型上算数运算符基本就是常见的数学用到的计算:+、-、*、/、%需要注意的是默认情况下,shell不会直接进行算术运算,而是把"算术符号"当做"字符串"与两个变量的值连接在......
  • MySQL入门学习-连接查询.INNER JOIN
        表的连接在数据库中扮演着至关重要的角色。当我们处理多个表之间的关联数据时,连接查询是必不可少的。    假设我们有两个表A和B,它们有一个共同的字段。现在,我们想从A和B中选择出所有匹配的数据。这就是连接查询的作用。    以下是一个基本的......
  • MySQL入门学习-子查询.列子查询
        列子查询是MySQL中一种常用的子查询类型,它返回一个单列的结果集,该结果集可以在主查询中作为一个列使用。一、以下是一些列子查询的例子:1.简单的列子查询```sqlSELECTcolumn1,    (SELECTcolumn2FROMtable2WHEREtable1.column1=table2.column......
  • mysql主从复制GTID模式
     版本8.0.36 主从复制的定义是指把数据从一个Mysql服务器(主节点)复制到一个或多个Mysql服务器(从节点)中,会把主节点服务器中的所有数据库实例、特定数据库实例或特定表等,全部复制到从节点服务器中。主从复制的原理是通过基于日志的复制方式实现数据的同步。当主服务器上发生数......
  • shell - 变量及数学计算
    变量声明#注意:以num=1为例,等号两边不能有空格#数字num=1#字符串str0=teststr1='test'str2="test"#字符串的三种声明方式是有区别的:#1.单引号中的内容回原样输出,不会转义,不会取值。#2.双引号中的内容输出,会转义,会取值。#3.没有引号和双引号效果一样。......
  • shell - 逻辑运算
    记录一些与或非相关的逻辑运算数字比较-eq等于,如:if["$a"-eq"$b"]-ne不等于,如:if["$a"-ne"$b"]-gt大于,如:if["$a"-gt"$b"]-ge大于等于,如:if["$a"-ge"$b"]-lt小于,如:if["$a&quo......
  • shell - 流程控制语句
    if条件语句ifconditionthen #dosth.elifconditionthen #doanother.else #doothers.fi#有些人喜欢这样写,看起来更紧凑一些ifcondition;then #dosth.elifcondition;then #doanother.else #doothers.fi样例:a=10;b=20;#下面这一句,方括号是......
  • 通过 HIDS 告警分析 webshell 行为
    准备漏洞环境1. 下载 vulhub 仓库gitclonehttps://github.com/vulhub/vulhub.git2.  修改 tomcat 弱口令漏洞环境配置vivulhub/tomcat/tomcat8/tomcat-users.xml将配置文件中的 user 和 password 修改为非弱口令3.  启动漏洞环境(根据实际 docker 环境......
  • Docker部署安装应用大集合(Tomcat、Nginx、Mysql、Redis、MQ、Nacos、Zookeeper、Port
    Docker部署安装应用大集合(Tomcat、Nginx、Mysql、Redis、MQ、Nacos、Zookeeper、Portainer、MongoDB......) 精选 原创CodeDevMaster2022-11-1608:42:24博主文章分类:Docker©著作权文章标签dockermysqlNginxNacosMQ文章分类Docker云计算yyds干货盘点 Docker部署......
  • 成为MySQL DBA后,再看ORACLE数据库(十一、闪回技术)
    前文说到ORACLE通过undo实现数据的多版本模型,同样的道理ORACLE还通过undo实现了闪回查询的特性,本文将总结ORACLE的几种闪回技术。闪回技术是Oracle数据库独有的特性,支持各级恢复,包括行、事务、表、表空间和数据库范围。采用闪回技术,可以针对行级和事务级发生过变化的数据进行恢复,......