Please wait while we load your page...

PasswordSentry

Latest Version [8.00202205221] Last Updated [May-22-2022]

Tools

PHP Manual [getSession]

Protect Your Website Today


PHP Manual || Mysql_xdevapi Functions

(No version information available, might only be in Git)

getSessionConnect to a MySQL server

Description

mysql_xdevapi\getSession ( string $uri ) : mysql_xdevapi\Session

Connects to the MySQL server.

Parameters

uri

The URI to the MySQL server, such as mysqlx://user:[email protected].

URI format:

scheme://[user[:[password]]@]target[:port][?attribute1=value1&attribute2=value2...

  • scheme: required, the connection protocol

    In mysql_xdevapi it is always 'mysqlx' (for X Protocol)

  • user: optional, the MySQL user account for authentication

  • password: optional, the MySQL user's password for authentication

  • target: required, the server instance the connection refers to:

    * TCP connection (host name, IPv4 address, or IPv6 address)

    * Unix socket path (local file path)

    * Windows named-pipe (local file path)

  • port: optional, network port of MySQL server.

    by default port for X Protocol is 33060

  • ?attribute=value: this element is optional and specifies a data dictionary that contains different options, including:

    • The auth (authentication mechanism) attribute as it relates to encrypted connections. For additional information, see » Command Options for Encrypted Connections. The following 'auth' values are supported: plain, mysql41, external, and sha256_mem.

    • The connect-timeout attribute affects the connection and not subsequent operations. It is set per connection whether on a single or multiple hosts.

      Pass in a positive integer to define the connection timeout in seconds, or pass in 0 (zero) to disable the timeout (infinite). Not defining connect-timeout uses the default value of 10.

      Related, the MYSQLX_CONNECTION_TIMEOUT (timeout in seconds) and MYSQLX_TEST_CONNECTION_TIMEOUT (used while running tests) environment variables can be set and used instead of connect-timeout in the URI. The connect-timeout URI option has precedence over these environment variables.

    • The optional compression attribute accepts these values: preferred (client negotiates with server to find a supported algorithm; connection is uncompressed if a mutually supported algorithm is not found), required (like "preferred", but connection is terminated if a mutually supported algorithm is not found), or disabled (connection is uncompressed). Defaults to preferred.

      This option was added in version 8.0.20.

Example #1 URI examples

mysqlx://foobar
mysqlx://[email protected]?socket=%2Ftmp%2Fmysqld.sock%2F
mysqlx://foo:[email protected]:33060
mysqlx://foo:[email protected]:33160?ssl-mode=disabled
mysqlx://foo:[email protected]:33260?ssl-mode=required
mysqlx://foo:[email protected]:33360?ssl-mode=required&auth=mysql41
mysqlx://foo:[email protected](/path/to/socket)
mysqlx://foo:[email protected](/path/to/socket)?auth=sha256_mem
mysqlx://foo:[email protected][localhost:33060, 127.0.0.1:33061]
mysqlx://foobar?ssl-ca=(/path/to/ca.pem)&ssl-crl=(/path/to/crl.pem)
mysqlx://foo:[email protected][localhost:33060, 127.0.0.1:33061]?ssl-mode=disabled
mysqlx://foo:[email protected]:33160/?connect-timeout=0
mysqlx://foo:[email protected]:33160/?connect-timeout=10&compression=required


PHP Manual || Mysql_xdevapi Functions