1.安装:官网下载安装包RPM 或者 源码包
使用YUM 源恩地安装
:yum localinstall mysql_shell*.rpm
2.进入msyql命令
mysqlsh --uri root@localhost:3306
使用\? 可以有提示介绍常用命令
命令 | 别名/快捷方式 | 描述 |
---|---|---|
|
| 打印有关MySQL Shell的帮助,或搜索在线帮助。 |
|
| 退出MySQL Shell。 |
| 在SQL模式下,开始多行模式。输入空行时,将缓存并执行代码。 | |
|
| 显示当前的MySQL Shell状态。 |
| 将执行模式切换为JavaScript。 | |
| 将执行模式切换为Python。 | |
| 将执行模式切换为SQL。 | |
|
| 连接到MySQL服务器。 |
| 重新连接到同一MySQL服务器。 | |
|
| 指定要使用的架构。 |
| \. or source (no backslash) | 使用活动语言执行脚本文件。 |
|
| 显示语句生成的任何警告。 |
|
| 不要显示语句生成的任何警告。 |
| 查看和编辑命令行历史记录。 | |
| 手动更新自动完成名称缓存。 | |
| 查询和更改MySQL Shell配置选项。 | |
| 使用提供的选项和参数运行指定的报告。 | |
| 使用提供的选项和参数运行指定的报告,并定期刷新结果。 | |
|
| 在默认系统编辑器中打开一个命令,然后将其显示在MySQL Shell中。 |
|
| 运行指定的操作系统命令,并在MySQL Shell中显示结果。 |
Option Name | Description | Introduced |
---|---|---|
-- | Start of API command line integration | |
--auth-method | Authentication method to use | |
--cluster | Connect to an InnoDB cluster | 8.0.4 |
--column-type-info | Print metadata for columns in result sets | 8.0.14 |
--compress | Compress all information sent between client and server | 8.0.14 |
--connect-timeout | Connection timeout for global session | 8.0.13 |
--credential-store-helper | The Secret Store helper for passwords | 8.0.12 |
--database | The schema to use (alias for --schema) | |
--dba | Enable X Protocol on connection with MySQL 5.7 server | |
--dba-log-sql | Log SQL statements that are executed by AdminAPI operations | 8.0.18 |
--dbpassword | Password to use when connecting to server | |
--dbuser | MySQL user name to use when connecting to server | |
--execute | Execute the command and quit | |
--file | File to process in batch mode | |
--force | Continue in SQL and batch modes even if errors occur | |
--get-server-public-key | Request RSA public key from server | |
--help | Display help message and exit | |
--histignore | Strings that are not added to the history | 8.0.3 |
--host | Host on which MySQL server instance is located | |
--import | Import JSON documents from a file or standard input | 8.0.13 |
--interactive | Emulate Interactive mode in batch mode | |
--js, --javascript | Start in JavaScript mode | |
--json | Print output in JSON format | |
--log-level | Specify logging level | |
-ma | Detect connection protocol for session automatically | 8.0.3 |
--mysql, -mc | Create a session using classic MySQL protocol | 8.0.3 |
--mysqlx, -mx | Create a session using X Protocol | 8.0.3 |
--name-cache | Enable automatic loading of table names based on the active default schema | 8.0.4 |
--no-name-cache | Disable autocompletion | 8.0.4 |
--no-password | No password is provided for this connection | |
--no-wizard, --nw | Disable the interactive wizards | |
--pager | The external pager tool used to display output | 8.0.13 |
--password | Password to use when connecting to server (alias for --dbpassword) | |
--passwords-from-stdin | Read the password from stdin | |
--port | TCP/IP port number for connection | |
--py, --python | Start in Python mode | |
--quiet-start | Start without printing introductory information | |
--recreate-schema | Drop and recreate schema | |
--redirect-primary | Ensure connection to an InnoDB cluster's primary | 8.0.4 |
--redirect-secondary | Ensure connection to an InnoDB cluster's secondary | |
--result-format | Set the output format for this session | 8.0.14 |
--save-passwords | How passwords are stored in the Secret Store | 8.0.12 |
--schema | The schema to use | |
--server-public-key-path | Path name to file containing RSA public key | |
--show-warnings | Show warnings after each statement if there are any (in SQL mode) | |
--socket | Unix socket file or Windows named pipe to use (classic MySQL protocol only) | |
--sql | Start in SQL mode, auto-detecting protocol to use for connection | |
--sqlc | Start in SQL mode using a classic MySQL protocol connection | |
--sqlx | Start in SQL mode using an X Protocol connection | 8.0.3 |
--ssl-ca | File that contains list of trusted SSL Certificate Authorities | |
--ssl-capath | Directory that contains trusted SSL Certificate Authority certificate files | |
--ssl-cert | File that contains X.509 certificate | |
--ssl-cipher | Name of the SSL cipher to use | |
--ssl-crl | File that contains certificate revocation lists | |
--ssl-crlpath | Directory that contains certificate revocation list files | |
--ssl-key | File that contains X.509 key | |
--ssl-mode | Desired security state of connection to server | |
--tabbed | Display output in tab separated format | |
--table | Display output in table format | |
--tls-version | Permissible TLS protocol for encrypted connections | |
--uri | Session information in URI format | |
--user | MySQL user name to use when connecting to server (alias for --dbuser) | |
--verbose | Activate verbose output to the console | 8.0.17 |
--version | Display version information and exit | |
--vertical | Display all SQL results vertically |
使用小技巧:
\? 加 命令可以有提示
tab 键 可以补全,提示命令;
‘’\‘’ 是mysqshell系统命令输入标记;
"var " 可以给全局变量赋值
官方手册介绍:官方手册文本