content_image/743925.jpg
You can specify a port number for connections to a local server, too. However, as indicated previously, connections to localhost  on Unix use a socket file by default, so unless you force a TCP/IP connection as previously described, any option that specifies a port number is ignored. 

For this command, the program uses a socket file on Unix and the --port  option is ignored: 

mysql --port=13306 --host=localhost 

To cause the port number to be used, force a TCP/IP connection. For example, invoke the program in either of these ways: 

mysql --port=13306 --host=127.0.0.1 mysql --port=13306 --protocol=TCP 

For additional information about options that control how client programs establish connections to the server, see Section 4.2.3, “Command Options for Connecting to the Server” . 

It is possible to specify connection parameters without entering them on the command line each time you invoke a client program: 

•Specify the connection parameters in the [client]  section of an option file. The relevant section of the file might look like this: 

[client] host= host_name user= user_name password= password 

For more information, see Section 4.2.2.2, “Using Option Files” . 

•Some connection parameters can be specified using environment variables. Examples: 

•To specify the host for mysql , use MYSQL_HOST . 

•On Windows, to specify the MySQL user name, use USER . 

For a list of supported environment variables, see Section 4.9, “Environment Variables” . 

## 4.2.5 Connecting to the Server Using URI-Like Strings or Key-Value Pairs 

This section describes use of URI-like connection strings or key-value pairs to specify how to establish connections to the MySQL server, for clients such as MySQL Shell. For information on establishing connections using command-line options, for clients such as mysql  or mysqldump , see Section 4.2.4, “Connecting to the MySQL Server Using Command Options” . For additional information if you are unable to connect, see Section 6.2.21, “Troubleshooting Problems Connecting to MySQL” . 

<img src='content_image/743925.jpg'>

## Note 

The term “URI-like”  signifies connection-string syntax that is similar to but not identical to the URI (uniform resource identifier) syntax defined by RFC 3986. 

The following MySQL clients support connecting to a MySQL server using a URI-like connection string or key-value pairs: 

•MySQL Shell 

•MySQL Connectors which implement X DevAPI 

This section documents all valid URI-like string and key-value pair connection parameters, many of which are similar to those specified with command-line options: 

