When you start MySQL Shell from the command line, you can
specify connection parameters using separate command options for
each value, such as the user name, host, and port. For
instructions and examples to start MySQL Shell and connect to a
MySQL Server instance in this way, see
Section 4.3.1, “Connecting using Individual Parameters”. When
you use this connection method, you can add one of these options
to choose the type of session object to create at startup to be
the session
global object:
For example, this command starts MySQL Shell and establishes an X Protocol connection to a local MySQL Server instance listening at port 33060:
$> mysqlsh --mysqlx -u user -h localhost -P 33060
If you are starting MySQL Shell in SQL mode, the
--sqlx
and
--sqlc
options include a choice
of session object type, so you can specify one of these instead
to make MySQL Shell use X Protocol or classic MySQL protocol for
the connection. For a reference for all the
mysqlsh command line options, see
Section A.1, “mysqlsh — The MySQL Shell”.
As an alternative to specifying the connection parameters using
individual options, you can specify them using a URI-like
connection string. You can pass in this string when you start
MySQL Shell from the command line, with or without using the
optional --uri
command option.
When you use this connection method, you can include the
scheme
element at the start of the URI-like
connection string to select the type of session object to
create. mysqlx
creates a
Session
object using X Protocol, or
mysql
creates a
ClassicSession
object using
classic MySQL protocol. For example, either of these commands uses a
URI-like connection string to start MySQL Shell and create a
classic MySQL protocol connection to a local MySQL Server instance
listening at port 3306:
$> mysqlsh --uri mysql://user@localhost:3306
$> mysqlsh mysql://user@localhost:3306
You can also specify the connection protocol as an option rather than as part of the URI-like connection string, for example:
$> mysqlsh --mysql --uri user@localhost:3306
For instructions and examples to connect to a MySQL Server instance in this way, see Connecting to the Server Using URI-Like Strings or Key-Value Pairs.
You may omit the connection protocol and let MySQL Shell automatically detect it based on your other connection parameters. For example, if you specify port 33060 and there is no option stating the connection protocol, MySQL Shell attempts to make the connection using X Protocol. If your connection parameters do not indicate the protocol, MySQL Shell first tries to make the connection using classic MySQL protocol, and if this fails, tries to make the connection using X Protocol.