20.4.1 MySQL Shell

This quick-start guide assumes a certain level of familiarity with MySQL Shell. The following section is a high level overview, see the MySQL Shell documentation for more information. MySQL Shell is a unified scripting interface to MySQL Server. It supports scripting in JavaScript and Python. JavaScript is the default processing mode.

该快速入门指南假定您对MySQL Shell已经有了一定程度的熟悉度。以下部分是一个高级概述,请参阅MySQL Shell文档以了解更多信息。MySQL Shell是MySQL服务器的统一脚本接口。它支持用JavaScript和Python编写脚本。JavaScript是默认的处理模式。

Start MySQL Shell

After you have installed and started MySQL server, connect MySQL Shell to the server instance. You need to know the address of the MySQL server instance you plan to connect to. To be able to use the instance as a Document Store, the server instance must have X Plugin installed and you should connect to the server using X Protocol. For example to connect to the instance ds1.example.com on the default X Protocol port of 33060 use the network string 

安装并启动MySQL服务器后,将MySQL Shell连接到服务器实例。您需要知道您计划连接到的MySQL服务器实例的地址。为了能够将实例用作文档存储,服务器实例必须安装X插件,并且您应该使用X协议连接到服务器。例如,连接到实例ds1.example.com ,实例默认X协议端口33060,连接实例如下:

user@ds1.example.com:33060.

Tip

If you connect to the instance using classic MySQL protocol, for example by using the default port of 3306 instead of the mysqlx_port, you cannot use the Document Store functionality shown in this tutorial. For example the db global object is not populated. To use the Document Store, always connect using X Protocol.

如果使用经典MySQL协议连接到实例,例如使用默认端口3306而不是mysqlx_port,则无法使用本教程中显示的文档存储功能。例如,db全局对象是不能被填充值得。要使用文档存储,请始终使用X协议进行连接。

If MySQL Shell is not already running, open a terminal window and issue:

如果MySQL Shell尚未运行,请打开终端窗口并执行:

mysqlsh user@ds1.example.com:33060/world_x

Alternatively, if MySQL Shell is already running use the \connect command by issuing:

或者,如果MySQL Shell已经在运行,请通过使用以下命令使用\connect:

\connect user@ds1.example.com:33060/world_x

You need to specify the address of the MySQL server instance which you want to connect MySQL Shell to. For example in the previous example:

您需要指定要连接MySQL Shell的MySQL服务器实例的地址。例如,在前面的示例中:

  • user represents the user name of your MySQL account.

  • user表示MySQL帐户的用户名。

  • ds1.example.com is the hostname of the server instance running MySQL. Replace this with the hostname of the MySQL server instance you are using as a Document Store.

  • ds1.example.com 是运行MySQL的服务器实例的主机名。将其替换为用作文档存储的MySQL服务器实例的主机名。

  • The default schema for this session is world_x. For instructions on setting up the world_x schema, see Section 20.4.2, “Download and Import world_x Database”.

  • 此会话的默认模式为world_x。有关设置world_x模式的说明,请参阅第  Section 20.4.2, “Download and Import world_x Database”.

For more information, see Section 4.2.5, “Connecting to the Server Using URI-Like Strings or Key-Value Pairs”.

Once MySQL Shell opens, the mysql-js> prompt indicates that the active language for this session is JavaScript. To switch MySQL Shell to Python mode, use the \py command.

MySQL Shell打开后,MySQL - js>提示符表明此会话的语言为JavaScript。要将MySQL Shell切换到Python模式,请使用\py命令。

mysql-js> \py

Switching to Python mode...

mysql-py>

MySQL Shell supports input-line editing as follows:

MySQL Shell支持输入行编辑,如下所示:

  • left-arrow and right-arrow keys move horizontally within the current input line.

  • 左箭头键和右箭头键在当前输入行内水平移动。

  • up-arrow and down-arrow keys move up and down through the set of previously entered lines.

  • 向上和向下箭头键在输入的行集合中上下移动。

  • Backspace deletes the character before the cursor and typing new characters enters them at the cursor position.

  • 退格删除光标前的字符,并在光标位置键入新字符。

  • Enter sends the current input line to the server.

  • Enter将当前输入行发送到服务器。

Get Help for MySQL Shell

Type mysqlsh --help at the prompt of your command interpreter for a list of command-line options.

在命令解释器的提示下键入mysqlsh--help以获取命令行选项列表

mysqlsh --help

Type \help at the MySQL Shell prompt for a list of available commands and their descriptions.

在MySQL Shell提示符处键入\help,以获取可用命令及其说明的列表。

mysql-py> \help

Type \help followed by a command name for detailed help about an individual MySQL Shell command. For example, to view help on the \connect command, issue:

键入\ help,后跟命令名,以获取有关单个MySQL Shell命令的详细帮助。例如,要查看\connect命令的帮助,请发出:

mysql-py> \help \connect

Quit MySQL Shell

To quit MySQL Shell, issue the following command:

要退出MySQL Shell,请发出以下命令:

mysql-py> \quit

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值