How to specify options for MySQL programs?

MySQLMySQLi Database

Let us understand how to specify options in MySQL programs. There are many ways in which options can be specified for MySQL programs −

Command Line

The options on the command line after entering the program name have to be listed. This is a common step for options which applies to a specific invocation of the program.

Option file

The options in an option file which the program reads when it starts also needs to be listed. This is a common step for options that the user needs the program to use every time it runs.

Environment Variables

The options in environment variables need to be listed. This method is helpful in options that require the user to apply the options every time the program runs.

In real life, the option files are used more commonly for this purpose, they can also be used to run multiple MySQL instances on Unix.

Options are processed in order. This means, if an option is specified multiple times, then the last occurrence of that option would take precedence.

The below command will cause mysql to connect to the server running on localhost −

mysql −h example.com −h localhost

MySQL programs help find which options are provided first by examining the environment variables. Then, the option files are processed, by checking the command line.

Since the latter options take precedence over former options, the processing order means that the environment variables have the lowest precedence whereas the command-line options have the highest precedence.

raja
Published on 09-Mar-2021 13:38:13
Advertisements