4.7 Program Development Utilities

This section describes some utilities that you may find useful when developing MySQL programs.

In shell scripts, you can use the note 'my_print_defaults': my-print-defaults. program to parse option files and see what options would be used by a given program. The following example shows the output that note 'my_print_defaults': my-print-defaults. might produce when asked to show the options found in the '[client]' and '[mysql]' groups:

 $> my_print_defaults client mysql
 --port=3306
 --socket=/tmp/mysql.sock
 --no-auto-rehash

Note for developers: Option file handling is implemented in the C client library simply by processing all options in the appropriate group or groups before any command-line arguments. This works well for programs that use the last instance of an option that is specified multiple times. If you have a C or C++ program that handles multiply specified options this way but that does not read option files, you need add only two lines to give it that capability. Check the source code of any of the standard MySQL clients to see how to do this.

Several other language interfaces to MySQL are based on the C client library, and some of them provide a way to access option file contents. These include Perl and Python. For details, see the documentation for your preferred interface.

 File: manual.info.tmp, Node: mysql-config, Next: my-print-defaults, Prev: programs-development, Up: programs-development

4.7.1 mysql_config -- Display Options for Compiling Clients

*note 'mysql_config': mysql-config. provides you with useful information for compiling your MySQL client and connecting it to MySQL. It is a shell script, so it is available only on Unix and Unix-like systems.

Note:

As of MySQL 5.7.9, 'pkg-config' can be used as an alternative to *note 'mysql_config': mysql-config. for obtaining information such as compiler flags or link libraries required to compile MySQL applications. For more information, see Building C API Client Programs Using pkg-config (https://dev.mysql.com/doc/c-api/5.7/en/c-api-building-clients-pkg-config.html).

Note:

As of MySQL 5.7.4, for binary distributions for Solaris, *note 'mysql_config': mysql-config. does not provide arguments for linking with the embedded library. To get linking arguments for the embedded library, use the 'mysql_server_config' script instead.

*note 'mysql_config': mysql-config. supports the following options.

If you invoke *note 'mysql_config': mysql-config. with no options, it displays a list of all options that it supports, and their values:

 $> mysql_config
 Usage: /usr/local/mysql/bin/mysql_config [options]
 Options:
   --cflags         [-I/usr/local/mysql/include/mysql -mcpu=pentiumpro]
   --cxxflags       [-I/usr/local/mysql/include/mysql -mcpu=pentiumpro]
   --include        [-I/usr/local/mysql/include/mysql]
   --libs           [-L/usr/local/mysql/lib/mysql -lmysqlclient
                     -lpthread -lm -lrt -lssl -lcrypto -ldl]
   --libs_r         [-L/usr/local/mysql/lib/mysql -lmysqlclient_r
                     -lpthread -lm -lrt -lssl -lcrypto -ldl]
   --plugindir      [/usr/local/mysql/lib/plugin]
   --socket         [/tmp/mysql.sock]
   --port           [3306]
   --version        [5.7.9]
   --libmysqld-libs [-L/usr/local/mysql/lib/mysql -lmysqld
                     -lpthread -lm -lrt -lssl -lcrypto -ldl -lcrypt]
   --variable=VAR   VAR is one of:
           pkgincludedir [/usr/local/mysql/include]
           pkglibdir     [/usr/local/mysql/lib]
           plugindir     [/usr/local/mysql/lib/plugin]

You can use note 'mysql_config': mysql-config. within a command line using backticks to include the output that it produces for particular options. For example, to compile and link a MySQL client program, use note 'mysql_config': mysql-config. as follows:

 gcc -c `mysql_config --cflags` progname.c
 gcc -o progname progname.o `mysql_config --libs`

 File: manual.info.tmp, Node: my-print-defaults, Next: resolve-stack-dump, Prev: mysql-config, Up: programs-development

4.7.2 my_print_defaults -- Display Options from Option Files

note 'my_print_defaults': my-print-defaults. displays the options that are present in option groups of option files. The output indicates what options are used by programs that read the specified option groups. For example, the note 'mysqlcheck': mysqlcheck. program reads the '[mysqlcheck]' and '[client]' option groups. To see what options are present in those groups in the standard option files, invoke *note 'my_print_defaults': my-print-defaults. like this:

 $> my_print_defaults mysqlcheck client
 --user=myusername
 --password=PASSWORD
 --host=localhost

The output consists of options, one per line, in the form that they would be specified on the command line.

*note 'my_print_defaults': my-print-defaults. supports the following options.

 File: manual.info.tmp, Node: resolve-stack-dump, Prev: my-print-defaults, Up: programs-development

4.7.3 resolve_stack_dump -- Resolve Numeric Stack Trace Dump to Symbols

*note 'resolve_stack_dump': resolve-stack-dump. resolves a numeric stack dump to symbols.

Note:

note 'resolve_stack_dump': resolve-stack-dump. is deprecated and is removed in MySQL 8.0. Stack traces from official MySQL builds are always symbolized, so there is no need to use note 'resolve_stack_dump': resolve-stack-dump.

Invoke *note 'resolve_stack_dump': resolve-stack-dump. like this:

 resolve_stack_dump [OPTIONS] SYMBOLS_FILE [NUMERIC_DUMP_FILE]

The symbols file should include the output from the 'nm --numeric-sort mysqld' command. The numeric dump file should contain a numeric stack track from *note 'mysqld': mysqld. If no numeric dump file is named on the command line, the stack trace is read from the standard input.

*note 'resolve_stack_dump': resolve-stack-dump. supports the following options.

For more information, see *note using-stack-trace::.

 File: manual.info.tmp, Node: programs-miscellaneous, Next: environment-variables, Prev: programs-development, Up: programs