After upgrading the server many users start it with an unchanged config file only to find some deprecated options that they were using are no longer supported by the later server version, which causes the upgraded server to shutdown. In other cases modifying the server configuration file results in the server refusing to start when an invalid name is mistakenly entered in the configuration file. In MySQL 5.7, users relied on using the combination of ‘help’ and ‘verbose’ options along with server configurations to test the options i.e.
1
2
3
4
|
./sql/mysqld --verbose --help --foo=bar To see what values a running MySQL server is using, type 'mysqladmin variables' instead of 'mysqld --verbose --help'. 2019-03-14T05:13:46.500953Z 0 [ERROR] Aborting |
In MySQL 8.0.16, a new option called ‘validate-config’ has been introduced to help users to quickly test the server configuration without having to run the server. If there are no issues found, the server exits with an exit code of zero. The server will exit with an error (error no 1) for first occurrence of an invalid configuration. For example, let us consider the server option ‘tx_read_only’ which was deprecated in MySQL 5.7 and removed MySQL 8.0:
1
2
3
4
|
./runtime_output_directory/mysqld --tx_read_only=on --validate-config 2019-03-30T10:40:02.712141Z 0 [ERROR] [MY-000067] [Server] unknown variable 'tx_read_only=on'. 2019-03-30T10:40:02.712178Z 0 [ERROR] [MY-010119] [Server] Aborting |
The validate-config option can also be used with a configuration file to check the options specified in the configuration file. For example:
1
2
3
4
5
|
./runtime_output_directory/mysqld --defaults-file=/home/nisha/workspace1/my.cnf --validate-config 2019-03-07T06:23:31.411188Z 0 [ERROR] [MY-000067] [Server] unknown variable 'tx_read_only=1'. 2019-03-07T06:23:31.411250Z 0 [ERROR] [MY-010119] [Server] Aborting |
Please note that when using the defaults-file option, it should be the first option on the command line as shown above.
Since the server exits on the first occurrence of an invalid value, correct the problem reported and re-run to find any further issues in the configuration settings.
By default only error messages are reported. If users are also interested in warning and information messages, the log_error_verbosity option needs to be mentioned
with a value greater than 1.
1
2
3
|
./runtime_output_directory/mysqld --log-error-verbosity=2 --validate-config --read_only=s --transaction_read_only=10 2019-03-09T11:10:01.270676Z 0 [Warning] [MY-000076] [Server] option 'read_only': boolean value 's' was not recognized. Set to OFF. 2019-03-09T11:10:01.270695Z 0 [Warning] [MY-000076] [Server] option 'transaction-read-only': boolean value '10' was not recognized. Set to OFF. |
As seen above, warnings about configuration settings are reported and the server exits
with zero since there are no errors. In the example below, an invalid configuration name
is mentioned, hence an error is reported along with the warnings and the server exits with
error code 1.
1
2
3
4
5
|
./runtime_output_directory/mysqld --log-error-verbosity=2 --validate-config --read_only=s --transaction_read_only=10 --foo=bar 2019-03-09T11:17:32.236782Z 0 [Warning] [MY-000076] [Server] option 'read_only': boolean value 's' was not recognized. Set to OFF. 2019-03-09T11:17:32.236796Z 0 [Warning] [MY-000076] [Server] option 'transaction-read-only': boolean value '10' was not recognized. Set to OFF. 2019-03-09T11:17:32.242247Z 0 [ERROR] [MY-000067] [Server] unknown variable 'foo=bar'. 2019-03-09T11:17:32.242327Z 0 [ERROR] [MY-010119] [Server] Aborting |
The scope of ‘validate-config’ is limited to validation of options which can be performed
without the normal start up of the server. Hence options specific to storage engines and plugins which are initialized during the normal start up of the server are not covered by ‘validate-config‘. Information about ‘validate-config‘ can also be found in the MySQL documentation. We hope this new option makes the lives of MySQL users easier especially during upgrades.
As always, THANK YOU for using MySQL!