
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
Command Options for Connecting to the MySQL Server
Let us see the options that are supported by MySQL client programs which control how client programs establish connections to the server, whether connections are encrypted, compressed or not.
These options can also be given on the command line or in an option file. The below mentioned command options can be used for connection establishment −
--default-auth: It is the authentication plugin that needs to be used.
--host: It is the host on which MySQL server is located.
--password: It is the password that needs to be used when connecting to server.
--pipe: It is used to connect to the server using named pipe. This is used on Windows only.
--plugin-dir: The directory where the plugins are installed.
--port: It is the TCP/IP port number used for connection.
--protocol: It is the transport protocol that is used.
--socket: It is the Unix socket file or Windows named pipe that is used.
--user: It refers to the MySQL user name that is used while connecting to the server.
--default-auth=plugin: It gives a hint about which client-side authentication plugin has to uses.
--host=host_name, -h host_name: It is the host on which the MySQL server runs. This value can be a host name, IPv4 address, or IPv6 address. The default value is the localhost.
--password[=pass_val], -p[pass_val]: The password of the MySQL account used for connecting to the server. The password value is optional.
--port=port_num, -P port_num: It is used for TCP/IP connections, where it determines the port number that needs to be used. The default port number is 3306.
--protocol={TCP|SOCKET|PIPE|MEMORY}: This option explicitly tells which transport protocol has to be used to connect to the serverLet us take an example −
Connections on Unix to localhost are made using a Unix socket file by default. It is shown below −
mysql --host=localhost
To force TCP/IP transport to be used instead of the default values, a --protocol option can be specified. It is shown below −
mysql --host=localhost --protocol=TCP
- Related Articles
- Connecting to the MySQL Server Using Command Options
- Connecting to and Disconnecting from the MySQL Server
- Connecting to MySQL database from the command line?
- Using Options on the Command Line for MySQL programs?
- How to upgrade MySQL server from command line?
- Python Parser for command line options
- After connecting to MySQL server how can we select a database from\ncommand prompt?
- MySQL Command-Line Options that Affect Option-File Handling
- Connecting to SAP HANA server on Cloud using PHP
- C-style parser for command line options in Python
- How to specify options for MySQL programs?
- Connecting to SAP R/3 system via JCo client and JCo Server
- How can we analyze the tables of a particular database from MySQL Server command line?
- Connecting to a MySQL database with Java
- MySQL command line client for Windows?
