# Using Options on the Command Line for MySQL programs?

MySQLMySQLi Database

Let us understand how to use options on command line for MySQL programs −

The program options which are specified on the command line follow the below rules −

• The options are given after the command name.

• An option argument begins with one dash or two dashes, and this depends on whether it is a short form or long form of the option name.

• Many options have both short and long forms. Let us take an example to understand this − −? and −−help are the short and long forms of the option which instructs a MySQL program to display the help message.

• The option names are case-sensitive. Both −v and −V are legal but have different meanings.

• They are the respective short forms of the −−verbose and −−version options.

Some options take up a value following the option name. Let us take an example to understand this −

## Example

−h localhost or −−host=localhost show the MySQL server host to a client program.

The option value gives information to the program about the name of the host where the MySQL server is running.

The MySQL server contains some command options that can be specified only at startup, and a set of system variables, out of which some of them can be set at startup, at runtime, or both.

System variable names use underscores instead of dashes. When they are referenced at runtime, they must be written using underscores as shown below −

## Query

SET GLOBAL general_log = ON;
SELECT @@GLOBAL.general_log;

During server startup, the syntax for system variables is the same as that of command options. Hence within variable names, dashes and underscores may be used interchangeably.

Published on 09-Mar-2021 13:39:03