# MySQL Command-Line Options that Affect Option-File Handling

MySQLMySQLi Database

Let us understand how MySQL command line options affect option file handling −

Many of the MySQL programs which support option files handle the below options. Since these options affect option-file handling, they must be provided on the command line and not in an option ile. For it to work properly, each of these options must be provided before other options, with the below mentioned exceptions −

−−print−defaults should be used immediately after −−defaults−file, −−defaults−extra−file, or −−loginpath.

On Windows, if the server startup is done with the --defaults-file and --install options, --install must be first.

--defaults-extra-file=file_name

On Unix, read the above line in option file after the global option file but ensure that it is before the user option file on all platforms before the login path file.

--login-path=name

It helps read the options from the named login path in the .mylogin.cnf login path file. A ‘login path’ is an option group that contains options which specifies the correct MySQL server that has to be connected to and which account has to be authenticated as.

To create or modify a login path file, the mysql_config_editor utility has to be used.

mysql --login-path=mypath

By default, the mysql client reads the [client] and [mysql] option groups. For the above command, mysql reads [client] and [mysql] from other option files, and [client], [mysql], and [mypath] will read from the login path file.

Client programs read the login path file even if the --no-defaults option is used. To specify an alternate login path file name, the MYSQL_TEST_LOGIN_FILE environment variable has to be set.

--print-defaults

It prints the program name and all options which it gets from option files. Password values are masked.

Published on 09-Mar-2021 13:40:47