arrow-left

Only this pageAll pages
gitbookPowered by GitBook
triangle-exclamation
Couldn't generate the PDF for 248 pages, generation stopped at 100.
Extend with 50 more pages.
1 of 100

Connectors

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Quickstart Guides

Dive into MariaDB Connectors with quickstart guides. Learn how to swiftly set up and use official client libraries (C, Java, Python, Node.js, ODBC) for seamless application connectivity.

MariaDB Connectors

Complete MariaDB Connectors guide. Complete reference for client libraries in Python, Java, Node.js, C, C++, ODBC, and R languages for production use.

rabbit-runningQuickstart Guideschevron-right
linkConnector/Cchevron-right
linkConnector/C++chevron-right
linkConnector/Jchevron-right
linkConnector/R2DBCchevron-right
link.NET Connectorchevron-right
linkConnector/Node.jschevron-right
linkConnector/ODBCchevron-right
linkConnector/Pythonchevron-right
plugOther Connectors & Methodschevron-right

Connector/C

The MariaDB Connector/C is used to connect applications developed in C/C++ to MariaDB and MySQL databases. MariaDB Connector/C is LGPLv2.1 licensed.

Building Connector/C From Source

Build MariaDB Connector/C from source. Download the package from MariaDB downloads or get the latest development version from the Connector/C GitHub repository.

MariaDB Connector/C API Functions

Explore API functions for MariaDB Connector/C. This section provides detailed documentation on functions for connecting, querying, and managing data, enabling robust C applications for MariaDB.

MariaDB Binlog/Replication API reference

These are currently documented on the github wikiarrow-up-right.

mariadb_cancel

hashtag
Syntax

int mariadb_cancel(MYSQL * mysql);

mysql - mysql handle, which was previously allocated by mysql_init() or mysql_real_connect().

hashtag
Description

Immediately aborts a connection by making all subsequent read/write operations fail.mariadb_cancel() does not invalidate memory used for mysql structure, nor close any communication channels. To free the memory, must be called.mariadb_cancel() is useful to break long queries in situations where sending KILL is not possible.

mariadb_cancel() was added in Connector/C 3.0

mysql_character_set_name

hashtag
Syntax

const char * mysql_character_set_name(MYSQL * mysql);

mysql - a mysql handle, which was previously allocated by mysql_init() or mysql_real_connect().

hashtag
Description

Returns the default client for the specified connection.

mysql_close

hashtag
Syntax

void mysql_close(MYSQL * mysql);

mysql - mysql handle, which was previously allocated by mysql_init() or mysql_real_connect().

hashtag
Description

Closes a previously opened connection.

mysql_commit

hashtag
Syntax

my_bool mysql_commit(MYSQL * mysql);
  • mysql - a mysql handle, which was previously allocated by mysql_init() or mysql_real_connect().

hashtag
Description

Commits the current transaction for the specified database connection. Returns zero on success, nonzero if an error occurred.

circle-info

Executing mysql_commit() will not affected the behaviour of . This means, any update or insert statements following mysql_commit() will be rolled back when the connection gets closed.

hashtag
See also

mysql_error

hashtag
Syntax

const char * mysql_error(MYSQL * mysql);
  • mysql - a mysql handle, which was previously allocated by mysql_init() or mysql_real_connect().

hashtag
Description

Returns the last error message for the most recent function call that can succeed or fail. If no error occurred an empty string is returned.

hashtag
See also

  • .

mysql_free_result

hashtag
Syntax

  • result - a result set identifier returned by mysql_store_result() or mysql_use_result().

hashtag
Description

Frees the memory associated with a result set. Returns void.

circle-info

You should always free your result set with mysql_free_result() as soon it's not needed anymore

Row values obtained by a prior call will become invalid after calling mysql_free_result().

hashtag
See also

mysql_num_rows

hashtag
Syntax

  • MYSQL_RES - a result set identifier returned by mysql_store_result() or mysql_use_result().

hashtag
Description

Returns number of rows in a result set.

circle-info

The behavior of mysql_num_rows() depends on whether buffered or unbuffered result sets are being used. For unbuffered result sets, mysql_num_rows() will not return the correbct number of rows until all the rows in the result have been retrieved.

hashtag
See also

MariaDB Connector/C++ Guide

Quickstart Guide for Connector/C++

hashtag
MariaDB Connector/C++ Quickstart Guide

MariaDB Connector/C++ allows your C++ applications to connect to MariaDB databases, including support for TLS encryption. It provides an object-oriented design and leverages smart pointers for efficient memory management.

circle-info

Erlang Guide

Quickstart Guide for MySQL/OTP (Erlang/OTP Client)


MySQL/OTP is the native Erlang/OTP client for connecting Erlang applications to MariaDB and MySQL databases, offering a direct implementation of the MySQL protocol.

hashtag
1. Installation

Add MySQL/OTP as a dependency in your rebar.config file (for rebar3 projects):

Prerequisites For Building Connector/C From Source

hashtag
Windows

  • Visual Studio 2013 or newer (older versions of Visual Studio may also work but have not been tested).

mysql_affected_rows

hashtag
Syntax

mysql is a connection identifier, which was previously allocated by or .

hashtag

mysql_data_seek

hashtag
Syntax

  • result - a result set identifier returned by mysql_store_result().

mysql_dump_debug_info

hashtag
Syntax

  • mysql - a mysql handle, which was previously allocated by or .

mysql_errno

hashtag
Syntax

  • mysql - a mysql handle, which was previously allocated by or .

mysql_escape_string

hashtag
Syntax

hashtag
Description

Escapes a string using the default character set.

mysql_fetch_field_direct

hashtag
Syntax

  • res - a result set identifier returned by or .

mysql_fetch_row

hashtag
Syntax

  • result - a result set identifier returned by or .

mysql_field_count

hashtag
Syntax

  • mysql - a mysql handle, which was previously allocated by or .

mysql_field_seek

hashtag
Syntax

  • result - a result set identifier returned by or .

mysql_get_character_set_info

hashtag
Syntax

  • mysql - a mysql handle, which was previously allocated by or .

mysql_get_server_info

hashtag
Syntax

  • mysql - a mysql handle, which was previously allocated by or .

mysql_hex_string

hashtag
Syntax

  • to - result buffer

mysql_init

hashtag
Syntax

mysql - a pointer to MYSQL or NULL. In case of passing a NULL pointer mysql_init() will allocate memory and return a pointer to a MYSQL structure.

hashtag

mysql_insert_id

hashtag
Syntax

  • mysql - a mysql handle, which was previously allocated by or .

mysql_options

hashtag
Syntax

  • mysql - a mysql handle, which was previously allocated by or .

mysql_library_end

hashtag
Syntax

hashtag
Description

Call when finished using the library, such as after disconnecting from the server. In an embedded server application, the embedded server is shut down and cleaned up. For a client program, only cleans up by performing memory management tasks.

mysql_get_ssl_cipher

hashtag
Syntax

  • mysql - a mysql handle, which was previously allocated by or .

mysql_server_end

hashtag
Syntax

hashtag
Description

mysql_server_end()

mysql_library_init

hashtag
Syntax

hashtag
Description

Call to initialize the library before calling other functions, both for embedded servers and regular clients. If used on an embedded server, the server is started and subsystems initialized. Returns zero for success, or nonzero if an error occurred.

mysql_get_proto_info

hashtag
Syntax

  • mysql - a mysql handle, which was previously allocated by or .

mysql_read_query_result

hashtag
Syntax

  • mysql - a mysql handle, which was previously allocated by or .

Returns zero on success, otherwise non-zero.

mysql_rollback

hashtag
Syntax

  • mysql - a mysql handle, which was previously allocated by or .

mysql_get_client_version

hashtag
Syntax

hashtag
Description

Returns a number representing the client library version.

mysql_fetch_lengths

hashtag
Syntax

  • result - a result set identifier returned by or .

mysql_get_client_info

hashtag
Syntax

hashtag
Description

Returns a string representing the client library version

mysql_num_fields

hashtag
Syntax

  • MYSQL RES * - A result set identifier returned by or .

mysql_server_init

hashtag
Syntax

hashtag
Description

mysql_server_init()

mysql_stat

hashtag
Syntax

  • mysql - a mysql handle, which was previously allocated by or .

void mysql_free_result(MYSQL_RES * result);
my_ulonglong mysql_num_rows(MYSQL_RES * );
The most recent Stable (GA) release is MariaDB Connector/C++ 1.1.6.

hashtag
Why Choose Connector/C++?

While you can use MariaDB Connector/C for C++ applications, Connector/C++ offers specific advantages for C++ development:

Feature

Connector/C++

Connector/C

Executes SQL

Yes

Yes

Object-Oriented

Yes

No

Smart Pointers

Yes

No

Implements JDBC API

Yes

No

hashtag
Next Steps

To get started with MariaDB Connector/C++, you'll typically need to:

  1. Download the Connector/C++ library. Look for the appropriate package for your operating system and development environment.

  2. Integrate the library into your C++ project. This usually involves including header files and linking against the library during compilation.

  3. Write C++ code to establish a connection, execute SQL queries, and process results using the object-oriented API.

This page is: Copyright © 2025 MariaDB. All rights reserved.

Erlang

Then, run rebar3 compile.

hashtag
2. Basic Usage

Here are essential steps for connecting and interacting with your database:

a. Connect:

Erlang

Replace placeholder values with your actual database credentials.

b. Execute Query:

Erlang

c. Close Connection:

Erlang

hashtag
Further Resources:

  • MySQL/OTP GitHub Repositoryarrow-up-right

  • Erlang/OTP Documentationarrow-up-right

cmake 2.8.12 or newer, available from the CMake websitearrow-up-right.
  • for Connector/C 2.x: OpenSSL libraries and include files.

  • for Connector/C 3.0 remote-io plugin: Curlarrow-up-right libraries and include files

  • hashtag
    Linux / Mac OS X

    The following is a list of tools that are required for building MariaDB Connector/C on Linux and Mac OS X. Most, if not all, of these will exist as packages in your distribution's package repositories, so check there first.

    • gcc 3.4.6 or newer C compiler

    • TLS/SSL libraries and include files

      • OpenSSL 1.0.1 or newer or

      • GnuTLS 3.4 or newer

    • cmake 2.8.12 or newer, available from the .

    • for Connector/C 3.0 remote-io plugin: libraries and include files

    • For GSSAPI plugin: libraries

    On Linux you can get those programs with your package manager. On Mac OS X you will need Xcode and to install the remaining programs with Finkarrow-up-right or MacPortsarrow-up-right.

    Description

    Returns the number of affected rows by the last operation associated with MySQL, if the operation was an "upsert" (, , or ) statement, or UINT64_MAX (0xffffffffffffffff) if the last query failed.

    circle-info

    When using , MariaDB will not update columns where the new value is the same as the old value. This creates the possibility that mysql_affected_rows may not actually equal the number of rows matched, only the number of rows that were literally affected by the query.

    The statement first deletes the record with the same primary key and then inserts the new record. This function returns the number of deleted records in addition to the number of inserted records.

    hashtag
    See also

    • mysql_num_rows()

    mysql_init()
    mysql_real_connect()
    offset - the field offset. Must be between zero and the total number of rows minus one (0..mysql_num_rows - 1).

    hashtag
    Description

    The mysql_data_seek() function seeks to an arbitrary function result pointer specified by the offset in the result set. Returns zero on success, nonzero if an error occurred.

    circle-info

    This function can only be used with buffered result sets obtained from the use of the mysql_store_result function.

    void mysql_data_seek(MYSQL_RES * result,
                         my_ulonglong offset);
    hashtag
    Description

    This function is designed to be executed by an user with the SUPER privilege and is used to dump server status information into the log for the MariaDB Server relating to the connection.

    Returns zero on success, nonzero if an error occurred.

    circle-info

    The server status information will be dumped into the file, which can usually be found in the data directory of your server installation.

    hashtag
    See also

    • mysql_debug()

    • mysql_debug_end()

    mysql_init()
    mysql_real_connect()
    hashtag
    Description

    Returns the last for the most recent function call that can succeed or fail. Zero means no error occurred.

    circle-info

    Client error messages are listed in errmsg.h header file, server error messages are listed in mysqld_error.h header file of the server source distribution.

    hashtag
    See also

    • mysql_error()

    • mysql_sqlstate()

    mysql_init()
    mysql_real_connect()
    triangle-exclamation

    This function is deprecated and will be discontinued. Please use mysql_real_escape_string() instead.

    hashtag
    See also

    • mysql_real_escape_string()

    unsigned long mysql_escape_string(char * to,
                                      const char * from,
                                      unsigned long);
    fieldnr - the field number. This value must be within the range from 0 to number of fields - 1

    hashtag
    Description

    Returns a pointer to a MYSQL_FIELD structure which contains field information from the specified result set.

    circle-info

    The total number of fields can be obtained by mysql_field_count()

    hashtag
    See also

    • mysql_fetch_field()

    • mysql_field_count()

    mysql_store_result()
    mysql_use_result()
    hashtag
    Description

    Fetches one row of data from the result set and returns it as an array of char pointers (MYSQL_ROW), where each column is stored in an offset starting from 0 (zero). Each subsequent call to this function will return the next row within the result set, or NULL if there are no more rows.

    circle-info

    If a column contains a NULL value the corresponding char pointer will be set to NULL.

    Memory associated to MYSQL_ROW will be freed when calling mysql_free_result() function.

    hashtag
    See also

    • mysql_use_result()

    • mysql_store_result()

    mysql_store_result()
    mysql_use_result()
    hashtag
    Description

    Returns the number of columns for the most recent query on the connection represented by the link parameter as an unsigned integer. This function can be useful when using the mysql_store_result() function to determine if the query should have produced a non-empty result set or not without knowing the nature of the query.

    circle-info

    The mysql_field_count() function should be used to determine if there is a result set available.

    hashtag
    See also

    • mysql_store_result()

    • mysql_use_result()

    mysql_init()
    mysql_real_connect()
    offset - the field number. This number must be in the range from 0..number of fields - 1.

    hashtag
    Description

    Sets the field cursor to the given offset. The next call to mysql_fetch_field() will retrieve the field definition of the column associated with that offset.

    Returns the previous value of the field cursor.

    circle-info

    The number of fields can be obtained from mysql_field_count().

    To move the field cursor to the first field offset parameter should be null.

    hashtag
    See also

    • mysql_field_tell()

    mysql_store_result()
    mysql_use_result()
    charset - a pointer to a MY_CHARSET_INFO structure, in which the information will be copied.

    hashtag
    Description

    Returns information about the current default for the specified connection.

    circle-info

    A complete list of supported character sets in the client library is listed in the function description for mysql_set_character_set_info().

    void mysql_get_character_set_info(MYSQL * mysql,
                                      MY_CHARSET_INFO * charset);
    mysql_init()
    mysql_real_connect()
    hashtag
    Description

    Returns the server version or NULL on failure.

    circle-info

    To obtain the numeric server version please use mysql_get_server_version().

    hashtag
    See also

    • mysql_get_server_version()

    • mysql_get_client_info()

    mysql_init()
    mysql_real_connect()
    from - the string which will be encoded
  • len - length of the string (from)

  • hashtag
    Description

    This function is used to create a hexadecimal string which can be used in SQL statements. e.g. INSERT INTO my_blob VALUES(X'A0E1CD').

    Returns the length of the encoded string without the trailing null character.

    circle-info

    The size of the buffer for the encoded string must be 2 * length + 1.

    The encoded string does not contain a leading X'.

    hashtag
    See also

    • mysql_real_escape_string()

    Description

    Prepares and initializes a MYSQL structure to be used with mysql_real_connect().

    If mysql_thread_init() was not called before, mysql_init() will also initialize the thread subsystem for the current thread.

    circle-info

    Members of the MYSQL structure are not intended for application use.

    Any subsequent calls to any mysql function (except mysql_options()) will fail until mysql_real_connect() was called.

    Memory allocated by mysql_init() must be freed with mysql_close().

    hashtag
    See also

    • mysql_real_connect()

    • mysql_options()

    • mysql_thread_init()

    hashtag
    Description

    The mysql_insert_id() function returns the ID generated by a query on a table with a column having the attribute or the value for the last usage of . If the last query wasn't an or statement or if the modified table does not have a column with the attribute and was not used, this function will return zero.

    circle-info

    When performing a multi-insert statement, mysql_insert_id() will return the value of the first row.

    hashtag
    See also

    • mysql_stmt_insert_id()

    mysql_init()
    mysql_real_connect()
    mysql_option - the option you want to set. See description below.
  • arg - the value for the option.

  • hashtag
    Description

    Used to set extra connect options and affect behavior for a connection. This function may be called multiple times to set several options. mysql_options() should be called after mysql_init() and before mysql_real_connect().

    Returns zero on success, non zero if an error occurred (invalid option or value).

    circle-exclamation

    This function is deprecated as of MariaDB Connector/C 3.0 and will be removed in future releases. It's preferable to use mysql_optionsv.

    hashtag
    Options

    See mysql_optionsv.

    hashtag
    See also

    • mysql_init()

    • mysql_optionsv

    • mysql_real_connect()

    mysql_init()
    mysql_real_connect()
    circle-info

    mysql_server_end() is an alias.

    hashtag
    See also

    • mysql_library_init()

    void mysql_library_end(void)
    hashtag
    Description

    Returns the name of the currently used cipher of the , or NULL for non TLS connections.

    hashtag
    See also

    • mysql_ssl_set()

    const char *mysql_get_ssl_cipher(MYSQL *mysql)
    mysql_init()
    mysql_real_connect()
    is an alias for
    .

    hashtag
    See also

    • mysql_library_init()

    • mysql_library_end()

    void mysql_server_end(void );
    mysql_library_end()

    Call mysql_library_end() to clean up after completion.

    circle-info

    mysql_server_init() is an alias.

    hashtag
    See also

    • mysql_library_end()

    int mysql_library_init(int argc, char **argv, char **groups)
    hashtag
    Description

    Returns the protocol version number for the specified connection

    circle-info

    The client library doesn't support protocol version 9 and prior.

    hashtag
    See also

    • mysql_get_host_info()

    unsigned int mysql_get_proto_info(MYSQL * mysql);
    mysql_init()
    mysql_real_connect()
    hashtag
    Description

    mysql_read_query_result() reads the result of a SQL statement executed with mysql_send_query(). If the SQL statement returned a resultset, it must be freed before the next call to mysql_read_query_result() is made. This is similar to how results from mysql_query() must be processed before another call can be made.

    int mysql_read_query_result(MYSQL * mysql);
    mysql_init()
    mysql_real_connect()
    hashtag
    Description

    Rolls back the current transaction for the database. Returns zero on success, nonzero if an error occurred.

    circle-info

    mysql_rollback() will not work as expected if mode was set or the storage engine does not support transactions.

    hashtag
    See also

    • mysql_commit()

    • mysql_autocommit()

    mysql_init()
    mysql_real_connect()
    circle-info

    To obtain a string containing the client library version use the mysql_get_client_info() function.

    hashtag
    See also

    • mysql_get_client_info()

    unsigned long mysql_get_client_version(void);
    hashtag
    Description

    The mysql_fetch_lengths() function returns an array containing the lengths of every column of the current row within the result set (not including terminating zero character) or NULL if an error occurred.

    circle-info

    mysql_fetch_lengths() is valid only for the current row of the result set. It returns NULL if you call it before calling mysql_fetch_row() or after retrieving all rows in the result.

    hashtag
    See also

    • mysql_fetch_row()

    mysql_store_result()
    mysql_use_result()
    circle-info

    To obtain the numeric value of the client library version use mysql_get_client_version().

    hashtag
    See also

    • mysql_get_client_version()

    • mysql_get_host_info()

    • mysql_get_proto_info()

    hashtag
    Description

    Returns number of fields in a specified result set.

    hashtag
    See also

    • mysql_fetch_field()

    unsigned int mysql_num_fields(MYSQL_RES * );
    mysql_store_result()
    mysql_use_result()
    is an alias for
    .

    hashtag
    See also

    • mysql_library_init()

    • mysql_library_end()

    void mysql_server_init(void );
    mysql_library_init()
    hashtag
    Description

    mysql_stat() returns a string with the current server status for uptime, threads, queries, open tables, flush tables and queries per second.

    circle-info

    For a complete list of other status variables, you have to use the SQL command.

    hashtag
    See also

    • mysql_get_server_info()

    mysql_init()
    mysql_real_connect()
    mysql_close()
    mysql_rollback()
    mysql_errno()
    mysql_sqlstate()
    mysql_fetch_row()
    mysql_store_result()
    mysql_use_result()
    mysql_affected_rows()
    mysql_use_result()
    mysql_store_result()

    MariaDB Connector/C Plugins

    MariaDB Connector/C functionality can be extended via loadable (or statically compiled in) plugins. As of the version 3.1.11 Connector/C comes with the following plugins

    hashtag
    connection plugins

    hashtag
    aurora

    hashtag
    replication

    hashtag
    pvio plugins

    These plugins are used by the Connector/C to communicate with the MariaDB server.

    hashtag
    socket

    hashtag
    npipe

    hashtag
    shmem

    hashtag
    io plugins

    These are plugins that are used whenever Connector/C needs to read a file. For example, for LOAD DATA LOCAL INFILE statement, when a server requests the Connector/C to send a specific file.

    hashtag
    remote_io

    This plugin uses libcurl to access remote files, it allows the client to execute statements like

    LOAD DATA LOCAL INFILE 'http://mariadb.com/example.csv' INTO t1

    Note that here, like with any LOAD DATA LOCAL, it'll be the client that fetches the file, not the server.

    This plugin supports the following url schemes: http://, https://, ftp://, sftp://, ldap://, smb://.

    hashtag
    auth plugins

    These are authentication plugins. They are loaded automatically by the Connector/C when the server requests a specific authentication method.

    hashtag
    mysql_native_password

    hashtag
    dialog

    This is a generic dialog plugin that asks the user a question (as instructed by the server) and sends the answer to the server. Everything is sent in plain text, one should enable SSL if secrets are sent via this plugin. Graphical clients can customize the plugin to provide graphical dialog form. See

    hashtag
    client_ed25519

    hashtag
    caching_sha2_password

    hashtag
    sha256_password

    hashtag
    auth_gssapi_client

    hashtag
    mysql_old_password

    hashtag
    mysql_clear_password

    Compiling Connector/C

    After successful configuration, Connector/C can now be compiled.

    hashtag
    Compiling on Windows

    If no CMake generator was specified, CMake creates by default build files for Visual Studio. You can now either build Connector/C inside Visual Studio

    devenv mariadb_connector_c.sln

    or via command line

    cmake --build . --config RelWithDebInfo

    hashtag
    Compiling on Unix

    By default CMake creates build files for GNU make. On some system GNU make is renamed to gmake. You can now build Connector/C with

    or

    mysql_autocommit

    hashtag
    Syntax

    my_bool mysql_autocommit(MYSQL * mysql, my_bool auto_mode);
    • mysql - a mysql handle, identifier, which was previously allocated by mysql_init() or mysql_real_connect().

    • auto_mode - whether to turn on or not.

    hashtag
    Description

    Toggles autocommit mode on or off for the current database connection. Autocommit mode will be set if mode=1 or unset if mode=0. Returns zero on success, or nonzero if an error occurred. Parameters

    circle-info

    mode only affects operations on transactional table types. To determine the current state of autocommit mode use the SQL command SELECT @@autocommit. Be aware: the function will not work if autocommit mode is switched on.

    hashtag
    Turning off autocommit in sql

    mysql_change_user

    hashtag
    Syntax

    • mysql - a mysql handle, which was previously allocated by mysql_init() or mysql_real_connect().

    • user - the user name for server authentication

    • passwd - the password for server authentication

    • db - the default database. If desired, the NULL value may be passed resulting in only changing the user and not selecting a database. To select a database in this case use the function.

    hashtag
    Description

    Changes the user and default database of the current connection.

    In order to successfully change users a valid username and password parameters must be provided and that user must have sufficient permissions to access the desired database. If for any reason authorization fails, the current user authentication will remain.

    Returns zero on success, nonzero if an error occured.

    circle-info

    mysql_change_user will always cause the current database connection to behave as if was a completely new database connection, regardless of if the operation was completed successfully. This reset includes performing a rollback on any active transactions, closing all temporary tables, and unlocking all locked tables.

    mysql_fetch_fields

    hashtag
    Syntax

    • res - a result set identifier returned by mysql_store_result() or mysql_use_result().

    hashtag
    Description

    This function serves an identical purpose to the function with the single difference that instead of returning one field at a time for each field, the fields are returned as an array. Each field contains the definition for a column of the result set.

    circle-info

    The total number of fields can be obtained by .

    hashtag
    See also

    mysql_info

    hashtag
    Syntax

    • mysql - a mysql handle, which was previously allocated by mysql_init() or mysql_real_connect().

    hashtag
    Description

    The mysql_info() function returns a string providing information about the last query executed. The nature of this string is provided below:

    Table 1. Possible mysql_info return values

    Query type
    Example result string
    circle-info

    Queries which do not fall into one of the preceding formats are not supported (e.g. ). In these situations, mysql_info() will return an empty string.

    hashtag
    See also

    mysql_query

    hashtag
    Syntax

    • mysql - a mysql handle, which was previously allocated by mysql_init() or mysql_real_connect().

    • query -a null terminated string containing the statement to be performed.

    hashtag
    Description

    Performs a statement pointed to by the null terminate string query against the database. Contrary to , mysql_query() is not binary safe.

    Returns zero on success, non zero on failure

    circle-info

    For executing multi statements the statements within the null terminated string statements must be separated by a semicolon.

    If your statement contains binary data you should use or escape your data with .

    To determine if a statement returned a result set use the function .

    hashtag
    See also

    mysql_fetch_field

    hashtag
    Syntax

    • result - a result set identifier returned by mysql_store_result() or mysql_use_result().

    hashtag
    Description

    Returns the definition of one column of a result set as a pointer to a MYSQL_FIELD structure. Call this function repeatedly to retrieve information about all columns in the result set.

    circle-info

    The field order will be reset if you execute a new SELECT query.

    In case only information for a specific field is required the field can be selected by using the function or obtained by function.

    hashtag
    See also

    mysql_kill

    hashtag
    Syntax

    • mysql - a mysql handle, which was previously allocated by mysql_init() or mysql_real_connect().

    • long - process id

    hashtag
    Description

    This function is used to ask the server to kill a MariaDB thread specified by the processid parameter. This value must be retrieved by . If trying to kill the own connection should be used.

    Returns 0 on success, otherwise nonzero.

    circle-info

    To stop a running command without killing the connection, use . The mysql_kill() function only kills a connection; it doesn't free any memory - this must be done explicitly by calling .

    hashtag
    See also

    mariadb_reconnect

    hashtag
    Syntax

    my_bool  mariadb_reconnect(MYSQL * mysql)
    • mysql - a mysql handle, which was previously allocated by mysql_init() or mysql_real_connect().

    hashtag
    Description

    mariadb_reconnect() tries to reconnect to a server in case the connection died due to timeout or other errors. It uses the same credentials which were specified in .

    The function will return 0 on sucess.

    The function will return an error, if the option MYSQL_OPT_RECONNECT wasn't specified before.

    This function was added in Connector/C 3.0.

    hashtag
    See also

    mysql_get_server_version

    hashtag
    Syntax

    unsigned long mysql_get_server_version(MYSQL * mysql);
    • mysql - a mysql handle, which was previously allocated by mysql_init() or mysql_real_connect().

    hashtag
    Description

    Returns an integer representing the version of connected server.

    circle-info

    The form of the version number is VERSION_MAJOR * 10000 + VERSION_MINOR * 100 + VERSION_PATCH

    hashtag
    See also

    mysql_select_db

    hashtag
    Syntax

    int mysql_select_db(MYSQL * mysql,
                        const char * db);
    • mysql - a mysql handle, which was previously allocated by mysql_init() or mysql_real_connect().

    • db - the default database name

    hashtag
    Description

    Selects a database as default. Returns zero on success, non-zero on failure

    circle-info

    The SQL command will return the name of the default database.

    The default database can also be set by the db parameter in .

    mysql_reset_connection

    hashtag
    Syntax

    • mysql - a MySQL handle, which was previously allocated by mysql_init() or mysql_real_connect().

    hashtag
    Description

    Resets the current connection and clears session state. Similar to or , mysql_reset_connection() resets session status, but without disconnecting, opening, or reauthenticating.

    On client side mysql_reset_connection()

    • clears pending or unprocessed result sets

    • clears status like affected_rows, info or last_insert_id

    • invalidates active prepared statements

    On server side mysql_reset_connection()

    • drops temporary table(s)

    • rollbacks active transaction

    • resets auto commit mode

    • releases table locks

    Returns zero on success, non-zero if an error occurred.

    This function was added in MariaDB Connector/C 3.0.0.

    mysql_real_query

    hashtag
    Syntax

    • mysql - a mysql handle, which was previously allocated by mysql_init() or mysql_real_connect().

    • query - a string containing the statement to be performed.

    • long - length of the string.

    hashtag
    Description

    mysql_real_query() is a binary-safe function for executing a statement on the database server. Returns zero on success, otherwise non-zero.

    circle-info

    Contrary to the function, mysql_real_query is binary safe.

    To determine if mysql_real_query returns a result set, use the function.

    hashtag
    See also

    mysql_row_seek

    hashtag
    Syntax

    • result - a result set identifier returned by mysql_store_result().

    • offset - row offset. This value can be obtained either by mysql_row_seek() or

    hashtag
    Description

    Positions the row cursor to an aribtrary row in a result set which was obtained by . Returns the previous row offset.

    circle-info

    This function will not work if the result set was obtained by .

    hashtag
    See also

    mysql_session_track_get_first

    hashtag
    Syntax

    • mysql - mysql handle, which was previously allocated by mysql_init() or mysql_real_connect().

    • type - type of information. Valid values are

      • SESSION_TRACK_SYSTEM_VARIABLES

      • SESSION_TRACK_SCHEMA

      • SESSION_TRACK_STATE_CHANGE

    • data - pointer to data, which must be declared as const char *

    • length - pointer to a size_t variable, which will contain the length of data

    hashtag
    Description

    mysql_session_track_get_first() retrieves the first session status change information received from the server.

    Depending on the specified type the read only data pointer will contain the following information:

    • SESSION_TRACK_SCHEMA: The name of the default schema (database)

    • SESSION_TRACK_SYSTEM_VARIABLES: If a session system variable is changed, the first call contains the name of the changed system variable, the second call contains the new value. Both name and value are represented as strings.

    • SESSION_TRACK_STATE_CHANGE

    Further data needs to be obtained by calling .

    mysql_session_track_get_first() was added in Connector/C 3.0 and MariaDB Server 10.2.

    hashtag
    Returns

    Zero for success, nonzero if an error occurred.

    hashtag
    See also

    mysql_set_local_infile_default

    hashtag
    Name

    mysql_set_local_infile_default - Sets local infile callback functions to default

    hashtag
    Synopsis

    hashtag
    Description

    Sets local infile callback functions to MariaDB Connector/C internal default callback functions.

    hashtag
    Parameter

    • mysql - mysql handle, which was previously allocated by

    hashtag
    See also

    mysql_send_query

    hashtag
    Syntax

    int mysql_send_query(MYSQL * mysql,
                         const char * query,
                         unsigned long length);
    • mysql - a mysql handle, which was previously allocated by mysql_init() or mysql_real_connect().

    • query - the query to execute.

    • length - length of query.

    Returns zero on success, otherwise non-zero.

    hashtag
    Description

    mysql_send_query() executes a SQL statement without waiting for the result. The main purpose of this function is to perform batch execution of DML statements.

    Each successful call tomysql_send_query() must be followed by a call to . Multiple calls to mysql_send_query() can be made before the calls to are done.

    mysql_shutdown

    hashtag
    Syntax

    int mysql_shutdown(MYSQL * mysql,
      enum mysql_enum_shutdown_level);
    • mysql - a mysql handle, which was previously allocated by mysql_init() or mysql_real_connect().

    • mysql_enum_shutdown_level - currently only one shutdown level, SHUTDOWN_DEFAULT is supported.

    hashtag
    Description

    Sends a shutdown message to the server. To shut down the database server, the user for the current connection must have SHUTDOWN privileges.

    Returns zero on success, non-zero on failure.

    hashtag
    See also

    mysql_sqlstate

    hashtag
    Syntax

    • mysql - a mysql handle, which was previously allocated by mysql_init() or mysql_real_connect().

    hashtag
    Description

    Returns a string containing the error code for the most recently invoked function that can succeed or fail. The error code consists of five characters. '00000' means no error. The values are specified by ANSI SQL and ODBC

    circle-info

    Please note that not all client library error codes are mapped to SQLSTATE errors. Errors which can't be mapped will be returned as value HY000.

    hashtag
    See also

    mysql_next_result

    hashtag
    Syntax

    • mysql - a mysql handle, which was previously allocated by mysql_init() or mysql_real_connect().

    hashtag
    Description

    Prepares next result set from a previous call to which can be retrieved by or . Returns zero on success, nonzero if an error occurred.

    circle-info

    If a multi query contains errors the return value of /error() might change and there will be no result set available.

    hashtag
    See also

    mysql_set_server_option

    hashtag
    Syntax

    • mysql - a mysql handle, which was previously allocated by mysql_init() or mysql_real_connect().

    • enum_mysql_set_option - server option (see below)

    hashtag
    Description

    Server option, which can be one of the following values:

    Option
    Description

    Returns zero on success, non-zero on failure.

    hashtag
    See also

    mysql_row_tell

    hashtag
    Syntax

    MYSQL_ROW_OFFSET mysql_row_tell(MYSQL_RES * res);
    • res - a result set identifier returned by mysql_store_result().

    hashtag
    Description

    Returns the row offset of a result cursor. The returned offset value can be used to reposition the result cursor by calling .

    circle-info

    This function will not work if the result set was obtained by .

    hashtag
    See also

    mysql_session_track_get_next

    hashtag
    Syntax

    • mysql - mysql handle, which was previously allocated by mysql_init() or mysql_real_connect().

    • type - type of information. Valid values are

      • SESSION_TRACK_SYSTEM_VARIABLES

      • SESSION_TRACK_SCHEMA

      • SESSION_TRACK_STATE_CHANGE

    • data - pointer to data, which must be declared as const char *

    • length - pointer to a size_t variable, which will contain the length of data

    hashtag
    Description

    mysql_session_track_get_next() retrieves the session status change information received from the server after a successful call to .

    mysql_session_track_get_next() needs to be called repeatedly until a non-zero return value indicates the end of data.

    mysql_session_track_get_next() was added in Connector/C 3.0 and MariaDB Server 10.2.

    hashtag
    Returns

    Zero for success, nonzero if an error occurred.

    hashtag
    See also

    mysql_get_host_info

    hashtag
    Syntax

    const char * mysql_get_host_info(MYSQL * mysql);
    • mysql - a mysql handle, which was previously allocated by mysql_init() or mysql_real_connect().

    hashtag
    Description

    Describes the type of connection in use for the connection, including the server host name. Returns a string, or NULL if the connection is not valid.

    hashtag
    See also

    mysql_ping

    hashtag
    Syntax

    • mysql - a mysql handle, which was previously allocated by or .

    mysql_more_results

    hashtag
    Syntax

    • mysql - a mysql handle, which was previously allocated by or .

    mysql_real_escape_string

    hashtag
    Syntax

    • mysql - a MySQL handle, which was previously allocated by or .

    mysql_field_tell

    hashtag
    Syntax

    • result - a result set identifier returned by or .

    mysql_thread_init

    hashtag
    Syntax

    hashtag
    Description

    Thread initialization for multi-threaded clients. Multi-threaded clients should call mysql_thread_init()

    mysql_thread_end

    hashtag
    Syntax

    hashtag
    Description

    The mysql_thread_end()

    mysql_ssl_set

    hashtag
    Syntax

    • mysql - a mysql handle, which was previously allocated by or .

    mysql_store_result

    hashtag
    Syntax

    • mysql - a mysql handle, which was previously allocated by or .

    {deps, [
        {mysql, ".*", {git, "https://github.com/mysql-otp/mysql-otp.git", {tag, "2.0.0"}}} % Use the latest stable tag
    ]}.
    {ok, Pid} = mysql:start_link([{host, "localhost"}, {user, "myuser"}, {password, "mypass"}, {database, "mydb"}]).
    % Select data
    {ok, ColumnNames, Rows} = mysql:query(Pid, <<"SELECT id, name FROM mytable WHERE status = ?">>, [<<"active">>]).
    
    % Insert data
    ok = mysql:query(Pid, "INSERT INTO mytable (col1, col2) VALUES (?, ?)", [<<"value1">>, 123]).
    mysql:stop(Pid).
    my_ulonglong mysql_affected_rows(MYSQL * mysql);
    int mysql_dump_debug_info(MYSQL * mysql);
    unsigned int mysql_errno(MYSQL * mysql);
    MYSQL_FIELD * mysql_fetch_field_direct(MYSQL_RES * res,
                                           unsigned int fieldnr);
    MYSQL_ROW mysql_fetch_row(MYSQL_RES * result);
    unsigned int mysql_field_count(MYSQL * mysql);
    MYSQL_FIELD_OFFSET mysql_field_seek(MYSQL_RES * result,
                                        MYSQL_FIELD_OFFSET offset);
    const char * mysql_get_server_info(MYSQL * mysql);
    unsigned long mysql_hex_string(char * to,
                                   const char * from,
                                   unsigned long len);
    MYSQL * mysql_init(MYSQL * mysql);
    my_ulonglong mysql_insert_id(MYSQL * mysql);
    int mysql_options(MYSQL * mysql,
                      enum mysql_option,
                      const void * arg);
    my_bool mysql_rollback(MYSQL * mysql);
    unsigned long * mysql_fetch_lengths(MYSQL_RES * result);
    const char * mysql_get_client_info(void );
    const char * mysql_stat(MYSQL * mysql);
    my_bool mysql_change_user(MYSQL * mysql,
                              const char * user,
                              const char * passwd,
                              const char * db);
    MYSQL_FIELD * mysql_fetch_fields(MYSQL_RES * res);
    const char * mysql_info(MYSQL * mysql);
    int mysql_query(MYSQL * mysql,
                    const char * query);
    MYSQL_FIELD * mysql_fetch_field(MYSQL_RES * result);
    int mysql_kill(MYSQL * mysql,
                   unsigned long);
    int mysql_reset_connection(MYSQL * mysql);
    int mysql_real_query(MYSQL * mysql,
                         const char * q,
                         unsigned long);
    MYSQL_ROW_OFFSET mysql_row_seek(MYSQL_RES * result,
        MYSQL_ROW_OFFSET offset);
    int mysql_session_track_get_first(MYSQL * mysql,enum enum_session_state_type type, const char **data, size_t *length );
    #include <mysql.h>
    
    void mysql_set_local_infile_default(MYSQL *conn);
    const char * mysql_sqlstate(MYSQL * mysql);
    int mysql_next_result(MYSQL * mysql);
    int mysql_set_server_option(MYSQL * mysql,
      enum enum_mysql_set_option);
    int mysql_session_track_get_next(MYSQL * mysql,enum enum_session_state_type type, const char **data, size_t *length );
    mysql_init()arrow-up-right
    mysql_set_local_infile_handler()
    mysql_use_result()
  • mysql_store_result()

  • mysql_real_query()
    mysql_real_query()
    mysql_hex_string()
    mysql_num_fields()
    mysql_real_query()
    mysql_num_fields()
    mysql_hex_string()
    mysql_store_result()
  • mysql_use_result()

  • mysql_field_seek()
    mysql_fetch_field_direct()
    mysql_field_seek()
    mysql_field_tell()
    mysql_fetch_field_direct()
  • initializes session variables (and sets them to the value of corresponding global variables)

  • closes active prepared statements

  • clears user variables

  • mysql_change_user()
    mariadb_reconnect()
    mysql_store_result()
    mysql_query()
    mysql_num_fields()
    mysql_query()
    mysql_num_fields()
    mysql_use_result()

    SESSION_TRACK_GTIDS (unsupported)

    : shows whether the session status has changed. The value is changed as string "1" (changed) or "0" (unchanged).
    mysql_session_track_get_next()
    mysql_session_track_get_next()
    mysql_more_results()
    mysql_real_query()
    mysql_store_result()
    mysql_use_result()
    mysql_errno
    mysql_real_query()
    mysql_store_result()
    mysql_use_result()

    SESSION_TRACK_GTIDS (unsupported)

    mysql_session_track_get_first()
    mysql_session_track_get_first()
    hashtag
    Description

    Checks whether the connection to the server is working. If it has gone down, and global option reconnect is enabled an automatic reconnection is attempted.

    Returns zero on success, nonzero if an error occured.

    This function can be used by clients that remain idle for a long while, to check whether the server has closed the connection and reconnect if necessary.

    circle-info

    If a reconnect occurred the thread_id will change. Also resources bundled to the connection (prepared statements, locks, temporary tables, ...) will be released.

    hashtag
    See also

    • mysql_options()

    • mysql_kill()

    mysql_init()
    mysql_real_connect()
    hashtag
    Description

    Indicates if one or more result sets are available from a previous call to mysql_real_query(). Returns 1 if more result sets are available, otherwise zero. .

    circle-info

    The function mysql_set_server_option() enables or disables multi statement support.

    hashtag
    See also

    • mysql_real_query()

    • mysql_use_result()

    • mysql_store_result()

    mysql_init()
    mysql_real_connect()
    to - buffer for the encoded string. The size of this buffer must be length * 2 + 1 bytes: in the worst case every character of the from string needs to be escaped. Additionally, a trailing 0 character will be appended.
  • from - a string which will be encoded by mysql_real_escape_string().

  • long - the length of the from string.

  • hashtag
    Description

    This function is used to create a legal SQL string that you can use in an SQL statement. The given string is encoded to an escaped SQL string, taking into account the current character set of the connection.

    Returns the length of the encoded (to) string.

    unsigned long mysql_real_escape_string(MYSQL * mysql,
                                           char * to,
                                           const char * from,
                                           unsigned long);
    mysql_init()
    mysql_real_connect()
    hashtag
    Description

    Return the offset of the field cursor used for the last mysql_fetch_field() call. This value can be used as a parameter for the function mysql_field_seek().

    Returns the current offset of the field cursor

    hashtag
    See also

    • mysql_field_seek()

    MYSQL_FIELD_OFFSET mysql_field_tell(MYSQL_RES * result);
    mysql_store_result()
    mysql_use_result()
    at the beginning of the thread initialization to initialize thread specific client library variables. If
    mysql_thread_init()
    was not called explicitly, it will be called automatically by
    or
    .

    Returns zero if successful or 1 if an error occurred.

    circle-info

    Before a client thread ends the mysql_thread_end() function must be called to release memory - otherwise the client library will report an error.

    circle-exclamation

    This function has been deprecated since MariaDB Connector/C 3.0.0.

    hashtag
    See also

    • mysql_thread_end()

    • mysql_thread_safe()

    mysql_init()
    mysql_real_connect()
    function needs to be called before a client thread ends. It will release thread-specific memory, which was allocated by a previous
    call. Returns void.
    circle-info

    Unlike mysql_thread_init() mysql_thread_end() will not be invoked automatically if the thread ends. To avoid memory leaks mysql_thread_end() must be called explicitly.

    circle-exclamation

    This function has been deprecated since MariaDB Connector/C 3.0.0.

    hashtag
    See also

    • mysql_thread_init()

    • mysql_thread_safe()

    mysql_thread_init()
    key - path to the key file.
  • cert - path to the certificate file.

  • ca - path to the certificate authority file.

  • capath - path to the directory containing the trusted TLS CA certificates in PEM format.

  • cipher list of permitted ciphers to use for TLS encryption.

  • hashtag
    Description

    Used for establishing a . It must be called before attempting to use mysql_real_connect(). TLS support must be enabled in the client library in order for the function to have any effect.

    NULL can be used for an unused parameter. Always returns zero.

    circle-info

    mysql_real_connect() will return an error if attempting to connect and TLS is incorrectly set up.

    hashtag
    See also

    • mysql_get_ssl_cipher()

    mysql_init()
    mysql_real_connect()
    hashtag
    Description

    Returns a buffered result set from the last executed query.

    circle-info

    mysql_store_result() returns NULL in case an error occurred or if the query didn't return data (e.g. when executing an or query.

    mysql_field_count() indicates if there will be a result set available.

    The memory allocated by mysql_store_result() needs to be released by calling the function mysql_free_result().

    hashtag
    See also

    • mysql_use_result()

    • mysql_real_query()

    • mysql_field_count()

    mysql_init()
    mysql_real_connect()
    make
    cmake --build . --config Release
    mysql_rollback()

    Records: 100 Duplicates: 0 Warnings: 0

    Records: 3 Duplicates: 0 Warnings: 0

    Records: 1 Deleted: 0 Skipped: 0 Warnings: 0

    Records: 3 Duplicates: 0 Warnings: 0

    Rows matched: 40 Changed: 40 Warnings: 0

    mysql_affected_rows()
    mysql_warning_count()

    MYSQL_OPTION_MULTI_STATEMENTS_OFF

    Disables multi statement support

    MYSQL_OPTION_MULTI_STATEMENTS_ON

    Enable multi statement support

    mysql_real_connect()
    CMake websitearrow-up-right
    Curlarrow-up-right
    Kerberos V5arrow-up-right
    mysql_close()
    mysql_select_db()
    mysql_fetch_field()
    mysql_field_count()
    mysql_fetch_field()
    mysql_fetch_field_direct()
    mysql_field_count()
    mysql_thread_id()
    KILL QUERYarrow-up-right
    mysql_close()
    mysql_thread_id()
    mysql_close()
    mariadb_cancel()
    mysql_real_connect()
    mysql_real_connect()
    mysql_options()
    mysql_get_server_info()
    mysql_real_connect()
    mysql_row_tell()
    mysql_store_result()
    mysql_use_result()
    mysql_store_result()
    mysql_row_tell()
    mysql_read_query_result()
    mysql_read_query_result()
    mysql_kill()
    SQLSTATEarrow-up-right
    mysql_error()
    mysql_errno()
    mysql_row_seek()
    mysql_use_result()
    mysql_store_result()
    mysql_row_seek()
    mysql_get_server_version()

    MariaDB Connector/C Guide

    Quickstart Guide for Connector/C

    hashtag
    MariaDB Connector/C Quickstart Guide

    This guide will help you quickly get started with MariaDB Connector/C, the client library used to connect C/C++ applications to MariaDB and MySQL databases. It's LGPL licensed and is being integrated directly into MariaDB Server distributions.

    hashtag
    Installation

    MariaDB Connector/C is often distributed with MariaDB Server packages, but you can also install it separately.

    hashtag
    Download Packages

    You can download MariaDB Connector/C packages directly:

    • From the downloads page: Select your desired version from the main MariaDB Connector/C download page.

    • By product selection: Choose "C/C++ connector" as the Product on the MariaDB downloads page.

    hashtag
    Install with a Package Manager (Recommended for Linux)

    If you're using Linux, the simplest way to install MariaDB Connector/C is via your system's package manager. Your system needs to be configured to install from a MariaDB repository (version 10.2 or later).

    You can set up your repository using:

    • MariaDB Corporation's .

    • MariaDB Foundation's .

    Install with yum/dnf (RHEL, CentOS, Fedora)

    For RHEL, CentOS, Fedora, and similar distributions, use yum or dnf:

    To install the shared library:

    To install the development package (if you're building applications):

    Install with apt-get (Debian, Ubuntu)

    For Debian, Ubuntu, and similar distributions, use apt-get:

    To install the shared library:

    To install the development package (if you're building applications):

    Install with zypper (SLES, OpenSUSE)

    For SLES, OpenSUSE, and similar distributions, use zypper:

    To install the shared library:

    To install the development package (if you're building applications):

    hashtag
    Install on Windows

    MariaDB Connector/C for Windows is distributed as MSI packages. The installation process is straightforward, with both 32-bit and 64-bit MSI packages available.

    hashtag
    Install from Source

    If you prefer to build from source, refer to the documentation.

    hashtag
    API Reference

    MariaDB Connector/C provides an API that is compatible with MySQL Connector/C for MySQL 5.5.

    You can find the function reference at:

    An HTML version is also available for download in mariadb-client-doc.zip.

    hashtag
    Configuration with Option Files

    Similar to MariaDB Server, MariaDB Connector/C can read configuration options from client option groups in option files.

    For detailed information, see .

    hashtag
    Known Issues

    Be aware of these potential limitations:

    • Double-to-string conversion for prepared statements may not work correctly.

    • Connector versions 3.0.7 and below do not support MySQL 8.0's default authentication protocol, caching_sha2_password. This should be supported in Connector/C 3.0.8 and above.

    hashtag
    Need Help or Want to Contribute?

    • Report Bugs: If you encounter a bug, please report it via the .

    • Source Code: The source code is available on GitHub in the .

    hashtag
    License

    GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

    For licensing questions, see the .

    mariadb_get_infov

    hashtag
    Syntax

    • mysql - a mysql handle, which was previously allocated by mysql_init() or mysql_real_connect(). For general information which is not bound to connection this parameter might be null.

    • value - the type of value you want to retrieve. See description below.

    • arg - pointer to a variable for storing value of the specified option.

    • ... - variable argument list

    hashtag
    Description

    Retrieves generic or connection specific information. Returns zero on success, non-zero if an error occurred (invalid option), This function was added in MariaDB Connector/C 3.0,

    hashtag
    Value types

    hashtag
    Generic information

    For these information types of parameters mysql needs to be set to NULL.

    • MARIADB_CHARSET_NAME: Retrieves the charset information for a character set by its literal representation.Parameter type: const MARIADB_CHARSET_INFO*.

    • MARIADB_CLIENT_ERRORS: Retrieve array of client errors. This can be used in plugins to set global error messages (which are not exported by MariaDB Connector/C).Parameter type: const char **.

    hashtag
    Connection related information

    • MARIADB_CONNECTION_ASYNC_TIMEOUT: Retrieves the timeout for non-blocking calls in seconds.Parameter type: unsigned int.

    • MARIADB_CONNECTION_ASYNC_TIMEOUT_MS: Retrieves the timeout for non-blocking calls in milliseconds.Parameter type: unsigned int.

    hashtag
    Examples

    hashtag
    See also

    mysql_get_optionv

    hashtag
    Syntax

    • mysql - a mysql handle, which was previously allocated by mysql_init() or mysql_real_connect().

    • mysql_option - the option you want to retrieve. See description below.

    • arg - pointer to a variable for storing value of the specified option.

    • ... - variable argument list

    hashtag
    Description

    Retrieves the value for a given option which was previously set by .

    Returns zero on success, non zero if an error occurred (invalid option).

    This function was added in MariaDB Connector/C 3.0.0.

    hashtag
    Options

    hashtag
    Boolean values (my_bool)

    • MYSQL_OPT_COMPRESS

    • MYSQL_OPT_NAMED_PIPE

    • MYSQL_OPT_RECONNECT

    • MYSQL_REPORT_DATA_TRUNCATION

    hashtag
    Integer values

    • MYSQL_OPT_CONNECT_TIMEOUT

    • MYSQL_OPT_READ_TIMEOUT

    • MYSQL_OPT_WRITE_TIMEOUT

    • MYSQL_OPT_LOCAL_INFILE

    hashtag
    Character arrays

    • MYSQL_INIT_COMMAND

    hashtag
    Character values

    • MYSQL_READ_DEFAULT_FILE

    • MYSQL_READ_DEFAULT_GROUP

    • MYSQL_SET_CHARSET_NAME

    • MYSQL_PLUGIN_DIR

    hashtag
    Misc

    • MYSQL_PROGRESS_CALLBACK: requires a function pointer *(const MYSQL *, uint, uint, double, const char *, uint))arg)

    • MYSQL_CONNECT_ATTRS: this option requires 5 parameters:

    • MARIADB_OPT_USERDATA: retrieves userdata for a given key.

    hashtag
    See also

    mysql_refresh

    hashtag
    Syntax

    • mysql - a mysql handle, which was previously allocated by mysql_init() or mysql_real_connect().

    • options - a bit masked composed integer. See below.

    hashtag
    Description

    Flushes different types of information stored on the server. The bit-masked parameter options specify which kind of information will be flushed. options can be any combination of the following:

    Option
    Description

    Returns zero on success, otherwise nonzero.

    circle-info

    To combine different values in the options parameter, use the OR operator '|'. The function mysql_reload() is an alias for mysql_refresh().

    mysql_real_connect

    hashtag
    Syntax

    • mysql - a mysql handle, which was previously allocated by mysql_init().

    • host - can be either a host name or an IP address. Passing the NULL value or the string "localhost" to this parameter, the local host is assumed. When possible, pipes will be used instead of the TCP/IP protocol.

    • user - the user name.

    • passwd - If provided or NULL, the server will attempt to authenticate the user against those user records which have no password only. This allows one username to be used with different permissions (depending on if a password as provided or not).

    • db - if provided will specify the default database to be used when performing queries.

    • port - specifies the port number to attempt to connect to the server.

    • unix_socket - specifies the socket or named pipe that should be used.

    • flags - the flags allows various connection options to be set:

      • CLIENT_FOUND_ROWS: Return the number of matched rows instead of number of changed rows.

      • CLIENT_NO_SCHEMA: Forbids the use of database.tablename.column syntax and forces the SQL parser to generate an error.

    hashtag
    Description

    Establishes a connection to a database server. Returns a MYSQL * handle or NULL if an error occurred.

    circle-info

    The password doesn't need to be encrypted before executing mysql_real_connect(). This will be handled in the client server protocol.

    The connection handle can't be reused for establishing a new connection. It must be closed and reinitialized before.

    hashtag
    See also

    mysql_thread_id

    hashtag
    Syntax

    • mysql - a mysql handle, which was previously allocated by mysql_init() or mysql_real_connect().

    hashtag
    Description

    The mysql_thread_id() function returns the thread id for the current connection.

    circle-info

    The current connection can be killed with . If reconnect option is enabled the thread id might change if the client reconnects to the server.

    circle-info

    Note that connector will return only the first 32connectionsbits value. If your database might expect to create more than 4.3 billion connections without a restart, it's better to query 'select CONNECTION_ID()'

    hashtag
    See also

    mysql_set_local_infile_handler

    hashtag
    Name

    mysql_set_local_infile_handler - Registers callback functions for LOAD DATA LOCAL INFILE

    hashtag
    Synopsis

    hashtag
    Description

    Registers four callback functions which will be called if a LOAD DATA LOCAL INFILE command will be executed.

    The initialization function accepts 3 parameters and returns zero on success, nonzero on error. It allocates an handle, which will be passed to read, end and error functions:

    int init(void **handle, const char *filename, void *userdata)

    The read function is called repeatly to read data chunks from file into buffer. The amount of bytes is limited by parameer buffer_len. The function returns the number of bytes which were read from the file:

    int mysql_local_infile_read(void *handle, char * buffer, unsigned int buffer_len)

    The end function will be called after the read function returned zero (no more bytes to read). To prevent leaking of resources, the file must be closed and handle must be freed inside this function:

    void end(void *handle);

    The error function is called to get an error message in case init, read or end functions returned an error.

    error(void *handler, char *error_buf, unsigned int error_buf_len);

    hashtag
    Parameter

    • mysql - mysql handle, which was previously allocated by

    • local_infile_init - initialization function, e.g. for opening the file

    • local_infile_read - read function

    hashtag
    See also

    MariaDB Connector/J Guide

    Quickstart Guide for Connector/J

    hashtag
    Quickstart Guide: MariaDB Connector/J

    MariaDB Connector/J is the official Java Database Connectivity (JDBC) driver for connecting Java applications to MariaDB and MySQL databases. It allows Java programs to interact with databases using the standard JDBC API.

    See for full content.

    MariaDB Connector/NET Guide

    Quickstart guide for MysqlConnector for ADO.NET

    hashtag
    Quickstart Guide: MariaDB Connector/NET (MySqlConnector)

    MariaDB Connector/NET, also known as MySqlConnector, is an ADO.NET data provider that enables .NET applications to connect and interact with MariaDB and MySQL databases. It's written entirely in C# and offers high performance and features specific to MariaDB Server.

    Connector/ODBC Guide

    Quickstart guide for MariaDB Connector/ODBC

    hashtag
    Quickstart Guide: MariaDB Connector/ODBC

    MariaDB Connector/ODBC is a database driver that allows applications to connect to MariaDB and MySQL databases using the Open Database Connectivity (ODBC) API. It's fully compliant with the ODBC 3.5 standard, open-source (LGPL), and can serve as a drop-in replacement for MySQL Connector/ODBC. It supports both Unicode and ANSI modes and communicates primarily using the MariaDB/MySQL binary protocol.

    Configuration Settings for Building Connector/C

    hashtag
    Configuration settings

    Connector/C specifies its build process with platform-independent CMake listfiles included in each directory of a source tree with the name CMakeLists.txt. Configuration settings may be specified by passing the -D option to CMake command line interpreter.

    mysql_debug

    hashtag
    Syntax

    • debug - a string representing the debug operation to perform. See description below.

    int mysql_ping(MYSQL * mysql);
    my_bool mysql_more_results(MYSQL * mysql);
    my_bool mysql_thread_init(void );
    void mysql_thread_end(void );
    my_bool mysql_ssl_set(MYSQL *mysql, const char *key, const char *cert,
      const char *ca, const char *capath, const char *cipher)
    MYSQL_RES * mysql_store_result(MYSQL * mysql);
    SET AUTOCOMMIT=0;
    int mariadb_get_infov(MYSQL * mysql,
                          enum mariadb_value value,
                          void * arg,
                          ...);
    int mysql_get_optionv(MYSQL * mysql,
                          enum mysql_option,
                          void * arg,
                          ...);
    int mysql_refresh(MYSQL * mysql,
      unsigned int options);
    MYSQL * mysql_real_connect(MYSQL * mysql,
                               const char * host,
                               const char * user,
                               const char * passwd,
                               const char * db,
                               unsigned int port,
                               const char * unix_socket,
                               unsigned long flags);
    unsigned long mysql_thread_id(MYSQL * mysql);
    #include <mysql.h>
    
    void STDCALL mysql_set_local_infile_handler(MYSQL *conn,
            int (*local_infile_init)(void **, const char *, void *),
            int (*local_infile_read)(void *, char *, uint),
            void (*local_infile_end)(void *),
            int (*local_infile_error)(void *, char *, uint),
            void *userdata);

    local_infile_end - terminating function, e.g. for closing the file

  • local_infile_error - error function

  • userdata - a buffer which will be passed to all callback function

  • mysql_init()arrow-up-right
    mysql_set_local_infile_default()
    hashtag
    1. Overview and Features

    MySqlConnector is licensed under the MIT License. It provides robust connectivity with features like:

    • Zero-configuration SSL: For MariaDB Server 11.4+.

    • Server Redirection Logic: Based on the latest MariaDB specification for MariaDB Server 11.3+.

    • Optimized SET NAMES handling: Avoids unnecessary commands for MariaDB Server 11.5+.

    • MariaDB GSSAPI Authentication: Support for secure authentication methods.

    • Asynchronous Operations: Fully supports async/await patterns for non-blocking database interactions.

    hashtag
    2. Installation

    The recommended way to install MySqlConnector is via NuGet.

    a. Using NuGet Package Manager Console (in Visual Studio):

    b. Using PackageReference (in your .csproj file):

    hashtag
    3. Basic Usage

    This section provides C# examples for connecting to MariaDB and performing common database operations.

    a. Connection String:

    A connection string defines how your application connects to the database. Replace placeholder values with your actual database details.

    b. Opening and Closing a Connection:

    Always ensure connections are properly opened and closed. The using statement is recommended as it ensures the connection is disposed of correctly, even if errors occur.

    c. Executing a SELECT Query:

    Use MySqlCommand to define your SQL query and ExecuteReaderAsync to retrieve data.

    d. Executing INSERT/UPDATE/DELETE Queries:

    Use ExecuteNonQueryAsync for operations that do not return a result set (like INSERT, UPDATE, DELETE). Always use parameterized queries to prevent SQL injection vulnerabilities.

    Install-Package MySqlConnector -Version 2.4.0 # Use the latest stable version
    <PackageReference Include="MySqlConnector" Version="2.4.0" /> ```
    
    **c. Using .NET CLI:**
    
    ```bash
    dotnet add package MySqlConnector --version 2.4.0 # Use the latest stable version
    string connectionString = "Server=localhost;Port=3306;Database=your_database_name;Uid=your_username;Pwd=your_password;";
    using MySqlConnector;
    using System;
    using System.Data;
    using System.Threading.Tasks;
    
    public class MariaDBConnectorNetQuickstart
    {
        private static string connectionString = "Server=localhost;Port=3306;Database=your_database_name;Uid=your_username;Pwd=your_password;";
    
        public static async Task Main(string[] args)
        {
            Console.WriteLine("Connecting to MariaDB...");
    
            try
            {
                await using var connection = new MySqlConnection(connectionString);
                await connection.OpenAsync();
                Console.WriteLine("Connection successful!");
    
                // Call your data operations here
                await SelectData(connection);
                await InsertData(connection);
    
                Console.WriteLine("Operations completed.");
            }
            catch (MySqlException ex)
            {
                Console.WriteLine($"Error: {ex.Message}");
            }
        }
    
        // ... (Data operation methods will go here)
    }
        private static async Task SelectData(MySqlConnection connection)
        {
            string query = "SELECT id, name FROM your_table_name;";
            await using var command = new MySqlCommand(query, connection);
    
            Console.WriteLine("\nRetrieving data:");
            await using var reader = await command.ExecuteReaderAsync();
            while (await reader.ReadAsync())
            {
                int id = reader.GetInt32("id");
                string name = reader.GetString("name");
                Console.WriteLine($"ID: {id}, Name: {name}");
            }
        }
        private static async Task InsertData(MySqlConnection connection)
        {
            string query = "INSERT INTO your_table_name (name, status) VALUES (@name, @status);";
            await using var command = new MySqlCommand(query, connection);
    
            command.Parameters.AddWithValue("@name", "New Item");
            command.Parameters.AddWithValue("@status", "active");
    
            int rowsAffected = await command.ExecuteNonQueryAsync();
            Console.WriteLine($"\nRows inserted: {rowsAffected}");
        }
    MARIADB_CLIENT_VERSION: The client version in literal representation.Parameter type: const char *.
  • MARIADB_CLIENT_VERSION_ID: The client version in numeric format.Parameter type: unsigned int.

  • MARIADB_MAX_ALLOWED_PACKET: Retrieves value of maximum allowed packet size.Parameter type: size_t

  • MARIADB_NET_BUFFER_LENGTH: Retrieves the length of net buffer.Parameter type: size_t

  • MARIADB_TLS_LIBRARY: The TLS library MariaDB Connector/C is compiled against.Parameter type: const char *.

  • MARIADB_CONNECTION_MARIADB_CHARSET_INFO: Retrieves character set information for given connection. Parameter type: const MY_CHARSET_INFO *.
  • MARIADB_CONNECTION_CLIENT_CAPABILITIES: Returns the capability flags of the client.Parameter type: unsigned long.

  • MARIADB_CONNECTION_ERROR: Retrieves error message for last used command. Parameter type: const char *.

  • MARIADB_CONNECTION_ERROR_ID: Retrieves error number for last used command. Parameter type: unsigned int.

  • MARIADB_CONNECTION_EXTENDED_SERVER_CAPABILITIES: Returns the extended capability flags of the connected MariaDB server.Parameter type: unsigned long.

  • MARIADB_CONNECTION_HOST: Retrieves connection's host name. Parameter type: const char *.

  • MARIADB_CONNECTION_INFO: Retrieves generic info for last used command.Parameter type: const char *.

  • MARIADB_CONNECTION_PORT: Retrieves the port number of server host.Parameter type: unsigned int.

  • MARIADB_CONNECTION_PROTOCOL_VERSION_ID: Retrieves the protocol version number.Parameter type: unsigned int.

  • MARIADB_CONNECTION_PVIO_TYPE: Retrives the pvio plugin used for specified connection.Parameter type: unsigned int.

  • MARIADB_CONNECTION_SCHEMA: Retrieves the current schema.Parameter type: const char*.

  • MARIADB_CONNECTION_SERVER_CAPABILITIES: Returns the capability flags of the connected server.Parameter type: unsigned long.

  • MARIADB_CONNECTION_SERVER_STATUS: Returns server status after last operation. A list of possible flags can be found in the description OK packet.Parameter type: unsigned int.

  • MARIADB_CONNECTION_SERVER_TYPE: Retrieves the type of the server.Parameter type: const char*.

  • MARIADB_CONNECTION_SERVER_VERSION: Retrieves the server version in literal format.Parameter type: const char *.

  • MARIADB_CONNECTION_SERVER_VERSION_ID: Retrieves the server version in numeric format.Parameter type: unsigned int.

  • MARIADB_CONNECTION_SOCKET: Retrieves the handle (socket) for given connection.Parameter type: my_socket.

  • MARIADB_CONNECTION_SQLSTATE: Retrieves current sqlstate information for last used command. Parameter type: const char *.

  • MARIADB_CONNECTION_SSL_CIPHER: Retrieves the TLS cipher in use.Parameter type: const char *.

  • MARIADB_CONNECTION_TLS_VERSION: Retrieves the TLS protocol version used in literal format.Parameter type: char *.

  • MARIADB_CONNECTION_TLS_VERSION_ID: Retrieves the TLS protocol version used in numeric format.Parameter type: unsigned int.

  • MARIADB_CONNECTION_UNIX_SOCKET: Retrieves the file name of the unix socketParameter type: const char *.

  • MARIADB_CONNECTION_USER: Retrieves connection's user name.Parameter type: const char *.

  • mysql_get_optionv()
  • MYSQL_OPT_NONBLOCK

  • MYSQL_OPT_SSL_VERIFY_SERVER_CERT

  • MARIADB_OPT_CONNECTION_READ_ONLY

  • MYSQL_SECURE_AUTH

  • MYSQL_OPT_PROTOCOL

  • MYSQL_OPT_SSL_KEY

  • MYSQL_OPT_SSL_CERT

  • MYSQL_OPT_SSL_CA

  • MYSQL_OPT_SSL_CAPATH

  • MYSQL_OPT_SSL_CRL

  • MYSQL_OPT_SSL_CRLPATH

  • MYSQL_OPT_SSL_CIPHER

  • MARIADB_OPT_SSL_FP

  • MARIADB_OPT_SSL_FP_LIST

  • MARIADB_OPT_SSL_PASSPHRASE

  • MYSQL_DEFAULT_AUTH

  • MYSQL_OPT_BIND

  • MARIADB_OPT_CONNECTION_HANDLER

  • mysql_optionsv
    mysql_optionsv()

    REFRESH_SLAVE

    Reset master server information and restart slaves.

    REFRESH_MASTER

    Remove binary log files.

    REFRESH_READ_LOCK

    REFRESH_FAST

    REFRESH_GRANT

    Refresh grant tables.

    REFRESH_LOG

    Flush logs.

    REFRESH_TABLES

    Flush table cache.

    REFRESH_HOSTS

    Flush host cache.

    REFRESH_STATUS

    Reset status variables.

    REFRESH_THREADS

    Flush thread cache.

  • CLIENT_COMPRESS: Use compression protocol

  • CLIENT_IGNORE_SPACE: Allows spaces after function names. All function names will become reserved words.

  • CLIENT_LOCAL_FILES: Allows LOAD DATA LOCAL statements

  • CLIENT_MULTI_STATEMENTS: Allows the client to send multiple statements in one command. Statements will be divided by a semicolon.

  • CLIENT_MULTI_RESULTS: Indicates that the client is able to handle multiple result sets from stored procedures or multi statements. This option will be automatically set if CLIENT_MULTI_STATEMENTS is set.

  • And others per .

  • mariadb_reconnect
    mysql_close()
    mysql_init()
    hashtag
    1. Installation

    You can include MariaDB Connector/J in your project using build tools like Maven or Gradle, or by manually adding the JAR file to your project's classpath.

    a. Using Maven:

    Add the following dependency to your pom.xml file:

    b. Using Gradle:

    Add the following dependency to your build.gradle file:

    c. Manual Installation:

    1. Download the latest stable .jar file from the MariaDB Downloads pagearrow-up-right.

    2. Add the downloaded .jar file to your project's classpath.

    hashtag
    2. Basic Usage (Connecting to MariaDB)

    Here's a simple Java example demonstrating how to establish a connection and execute a basic query using DriverManager.

    Before Running:

    1. Replace your_database_name, your_username, your_password, and your_table_name with your actual database details.

    2. Ensure you have a MariaDB server running and a database/table set up.

    hashtag
    3. Connection Strings

    MariaDB Connector/J supports various connection string formats, including options for failover and load balancing. The basic format is:

    jdbc:mariadb://<hostDescription>[,<hostDescription>...]/[database][?<key1>=<value1>[&<key2>=<value2>]]

    For example:

    • jdbc:mariadb://localhost:3306/mydb

    • jdbc:mariadb://server1:3306,server2:3306/mydb?failover=true

    hashtag
    4. Connection Pooling (for Production)

    For production applications, it's highly recommended to use a connection pool to manage database connections efficiently. MariaDB Connector/J can be used with external connection pooling libraries like HikariCP or Apache Commons DBCP, or its own MariaDbPoolDataSource.

    • MariaDbDataSource: Creates a new connection each time.

    • MariaDbPoolDataSource: Maintains a pool of connections for reuse.

    When using an external pool, configure it to use org.mariadb.jdbc.Driver as the JDBC driver class.

    About MariaDB Connector/Jarrow-up-right
    hashtag
    1. What is ODBC?

    ODBC (Open Database Connectivity) is a standard API for accessing database management systems (DBMS). It provides a common way for applications to communicate with different databases, abstracting away the specifics of each database's native communication protocol. MariaDB Connector/ODBC acts as the specific bridge for MariaDB.

    hashtag
    2. Installation

    Installation typically involves downloading the appropriate driver package for your operating system and configuring a Data Source Name (DSN).

    a. Windows:

    1. Download: Go to the MariaDB Connector/ODBC Downloads pagearrow-up-right and download the appropriate .msi installer for your Windows version (32-bit or 64-bit).

    2. Run Installer: Execute the downloaded .msi file and follow the on-screen instructions. This will install the necessary driver files.

    3. Configure DSN:

      • Open the ODBC Data Source Administrator:

        • For 64-bit systems, search for "ODBC Data Sources (64-bit)".

        • For 32-bit systems, search for "ODBC Data Sources (32-bit)".

    b. Linux / macOS:

    1. Download: Download the appropriate .deb, .rpm, or .pkg package from the MariaDB Connector/ODBC Downloads pagearrow-up-right.

    2. Install Package:

      • Debian/Ubuntu: sudo dpkg -i mariadb-connector-odbc_X.Y.Z.deb

      • Red Hat/CentOS: sudo rpm -i mariadb-connector-odbc-X.Y.Z.rpm

      • macOS: Run the .pkg installer.

    3. Configure odbcinst.ini and odbc.ini:

      • The installer usually places the driver definition in /etc/odbcinst.ini (or a similar location).

    4. Test DSN (Optional): You can use isql (from unixodbc-dev or unixodbc package) to test your DSN:

    hashtag
    3. Basic Usage (Connecting from Applications)

    Once the MariaDB ODBC driver is installed and a DSN is configured, applications can connect to your MariaDB database using the standard ODBC API. The exact code will vary depending on the programming language and framework you are using (e.g., C++, Java with JDBC-ODBC Bridge, Python with pyodbc, PHP with odbc extension).

    a. Connecting via DSN (Common for many applications):

    Many applications and tools (like Microsoft Excel, reporting tools, or C++ applications using ODBC) will allow you to select a configured DSN directly.

    b. Connecting via DSN-less Connection String:

    You can also provide a full connection string directly in your application without pre-configuring a DSN. This is often used in scripting languages or when you need more dynamic control.

    Replace {MariaDB ODBC Driver} with the exact driver name from your odbcinst.ini if different.

    hashtag
    Further Resources:

    • MariaDB Connector/ODBC Documentation

    • MariaDB Connector/ODBC Downloadsarrow-up-right

    Do not build Connector/C from the root of the source tree: Either create a subdirectory "build" inside the source tree or create a subdirectory outside of the source tree.

    Example:

    hashtag
    Reconfiguration

    In case Connector/C was already configured, the CMakeCache.txt file needs to be removed first. In several cases, e.g. when cross compiling CMakeFiles subfolders need to be removed too.

    hashtag
    Generator options

    If you want to use a different generator, e.g. for nmake on Windows, you need to specify the generator with the -G option. cmake --help lists the available generators for the used platform.

    hashtag
    CMake-related configuration settings

    CMAKE_BUILD_TYPE

    Build type: Release, RelWithDebInfo or Debug

    CMAKE_INSTALL_PREFIX

    Installation base directory

    CMAKE_C_FLAGS

    Flags for C-Compiler

    hashtag
    TLS/SSL options

    Option

    Default

    Description

    WITH_OPENSSL

    ON

    Possible values are ON or OFF. Not supported anymore since Connector/C 3.0

    WITH_SSL

    SCHANNEL (windows), otherwise OPENSSL

    Specifies type of TLS/SSL library. E.g. GNUTLS, OPENSSL or SCHANNEL (Windows only). OFF disables TLS/SSL functionality

    hashtag
    Client plugins

    Client plugins can be configured as dynamic plugins (DYNAMIC) or built-in plugins (STATIC) by specifying the plugin name followed by suffix _PLUGIN_TYPE as key, and "DYNAMIC" or "STATIC" as value.

    E.g. for building dialog plugin as a built-in plugin, for versions < Connector/C 3.0.4

    Beginning with C/C 3.0.4

    Connector/C 3.0 supports the following plugins:

    Plugin

    Type

    Default

    Description

    SOCKET

    IO

    static

    plugin for client server communication via socket

    SHMEM

    IO

    static

    plugin for client server communication via shared memory

    NPIPE

    IO

    static

    plugin for client server communication via named pipe

    hashtag
    Description

    Enables debug output for development and debug purposes by using Fred Fish's DBUG library. For using this function the mariadb-client library must be compiled with debug support.

    Almost all MariaDB binaries use the DBUG library and one can get a trace of the program execution by using the command line option with the binary. This will only work if the binary is compiled for debugging (compiler option -DDBUG_ON).

    Returns void.

    The debug control string is a sequence of colon separated fields as follows:

    Each field consists of a mandatory flag character followed by an optional "," and comma separated list of modifiers:

    The currently recognized flag characters are:

    Option
    Description

    d

    Enable output from DBUG_ macros for the current state. May be followed by a list of keywords which selects output only for the DBUG macros with that keyword. A null list of keywords implies output for all macros.

    D

    Delay after each debugger output line. The argument is the number of tenths of seconds to delay, subject to machine capabilities. I.E. -#D,20 is delay two seconds.

    f

    Limit debugging and/or tracing, and profiling to the list of named functions. Note that a null list will disable all functions. The appropriate "d" or "t" flags must still be given, this flag only limits their actions if they are enabled.

    F

    Identify the source file name for each line of debug or trace output.

    i

    Identify the process with the pid for each line of debug or trace output.

    g

    Enable profiling. Create a file called 'dbugmon.out' containing information that can be used to profile the program. May be followed by a list of keywords that select profiling only for the functions in that list. A null list implies that all functions are considered.

    circle-info

    Instead of using the mysql_debug() function you also can set the environment variable MYSQL_DEBUG\

    Enabling generation of debug information slows down the overall performance and generates huge files. In case you need debug information only for special places you can disable the generation of debug information by using mysql_debug_end().

    hashtag
    See also

    • mysql_debug_end()

    • mysql_dump_debug_info()

    Building Connector/C From Source
    MariaDB Client Library for C API Functions
    MariaDB Client Library for C API Prepared Statement Functions
    Configuring MariaDB Connector/C with Option Files
    CONC project on MariaDB's Jira bug trackerarrow-up-right
    mariadb-connector-c repositoryarrow-up-right
    mysql_next_result()
    mysql_kill()
    mysql_kill()
    mysql_options()

    Connector/Python Guide

    Quickstart guide for MariaDB Connector/Python

    hashtag
    Quickstart Guide: MariaDB Connector/Python

    MariaDB Connector/Python is the official Python client library for connecting applications to MariaDB and MySQL databases. It implements the Python DB API 2.0 (PEP-249) standard, ensuring compatibility with common Python database programming patterns. The connector is written in C and Python and relies on the MariaDB Connector/C client library for efficient client-server communication.

    hashtag
    1. Prerequisites

    Before installing MariaDB Connector/Python, ensure you have:

    • Python: Version 3.7 or later.

    • MariaDB Connector/C: Version 3.1.5 or later (for Connector/Python 1.0) or 3.3.1 or later (for Connector/Python 1.1+). On Windows, this is often handled by the pip installation; on Linux/macOS, you typically need to install libmariadb-dev or equivalent development packages via your system's package manager.

    hashtag
    2. Installation

    The easiest way to install MariaDB Connector/Python is using pip, Python's package installer:

    This command downloads and installs the latest stable version of the connector from PyPI.

    hashtag
    3. Basic Usage

    Here's a simple Python example demonstrating how to connect to MariaDB, execute queries, and manage transactions.

    Before Running:

    1. Replace your_username, your_password, and your_database_name with your actual MariaDB server credentials.

    2. Ensure you have a MariaDB server running and the specified database exists.

    3. The example assumes your_table_name

    hashtag
    Important Notes:

    • Parameterized Queries: Always use parameterized queries (e.g., VALUES (?, ?)) to prevent SQL injection vulnerabilities. Parameters are passed as a tuple or list to the execute() method.

    • Transactions (conn.commit() / conn.rollback()): By default, MariaDB Connector/Python may have autocommit enabled. If you need explicit transaction control, ensure you call conn.commit()

    hashtag
    Further Resources:

    Connector/Ruby Guide

    Quickstart guide for Connector/Ruby

    hashtag
    Quickstart Guide: MariaDB Connector/Ruby (using mysql2 gem)

    While there isn't a separate "MariaDB Connector/Ruby" gem, the widely used mysql2 gem serves as the primary and highly compatible Ruby client for connecting to both MariaDB and MySQL databases. It provides a robust API for database interactions in Ruby applications.

    hashtag
    1. Overview

    The mysql2 gem provides a Ruby interface to the MariaDB/MySQL C client library (either libmysqlclient or MariaDB Connector/C). It allows Ruby applications to execute SQL queries, fetch results, and manage database connections efficiently. It's available on .

    hashtag
    2. Installation

    Before installing the mysql2 gem, you might need to install development libraries for MariaDB Connector/C or MySQL Client on your system.

    a. Install System Dependencies (e.g., on Debian/Ubuntu):

    On other systems (Fedora, CentOS, macOS), the package names might differ (e.g., mariadb-devel, mysql-devel).

    b. Install the mysql2 gem:

    Once the system dependencies are in place, install the gem using Bundler (recommended for Rails/Gemfile projects) or directly via gem install:

    hashtag
    3. Basic Usage

    Here's how to connect to MariaDB and perform common database operations using the mysql2 gem:

    a. Connect to the Database:

    Replace localhost, 3306, your_username, your_password, and your_database_name with your actual database details.

    b. Execute a SELECT Query:

    The results object behaves like an enumerable, allowing you to iterate over rows. Column names are accessible as hash keys.

    c. Execute INSERT/UPDATE/DELETE Queries:

    For data manipulation, use query. For safety, always use prepared statements or proper escaping for user-provided input.

    d. Prepared Statements (Recommended for security and performance):

    Prepared statements allow you to separate the SQL query structure from the data, preventing SQL injection and improving performance for repeated queries.

    Before Running:

    1. Ensure you have a MariaDB server running and a database/table set up.

    2. Replace placeholder values with your actual database credentials and table/column names.

    hashtag
    Important Notes:

    • Error Handling: Always wrap your database operations in begin...rescue...end blocks to catch Mysql2::Error exceptions.

    • Connection Closing: Ensure your Mysql2::Client connection is closed using client.close in a ensure block to release database resources.

    hashtag
    Further Resources:

    MariaDB Connector/C Overview

    Complete Connector/C reference: Windows MSI install, Linux packages (yum/apt/zypper), MariaDB-shared/devel libraries, and option file configuration.

    circle-info

    Browse & download the latest MariaDB connectors

    Download Connectors

    circle-info

    The most recent release of is:

    hashtag

    MariaDB Connector/C is used to connect applications developed in C/C++ to MariaDB and MySQL databases.The client library is LGPL licensed.

    hashtag
    Integration with MariaDB Server

    MariaDB Connector/C is distributed with MariaDB Server packages. Eventually, it will completely replace the functionality that has traditionally been performed by libmysqlclient in those packages. Currently, MariaDB Connector/C has replaced libmysqlclient as the client library for client utilities that are distributed with MariaDB Server. See for more information.

    hashtag
    Installing MariaDB Connector/C

    MariaDB Connector/C packages can be downloaded by selecting your desired version from the following page:

    • MariaDB Connector/C packages can also be downloaded by selecting C/C++ connector as the Product on the following page:

    See the instructions below for information on how to install the MariaDB Connector/C package for your operating system.

    hashtag
    Installing MariaDB Connector/C on Windows

    To install MariaDB Connector/C on Windows, we distribute . The MSI installation process is fairly straightforward. Both 32-bit and 64-bit MSI packages are available.

    hashtag
    Installing MariaDB Connector/C on Linux

    MariaDB Connector/C is distributed in on Linux.

    hashtag
    Installing with a Package Manager

    Since MariaDB Connector/C is now integrated with MariaDB Server, it can also be installed via a package manager on Linux. In order to do so, your system needs to be configured to install from one of the MariaDB repositories. The repository needs to be configured for or later.

    You can configure your package manager to install it from MariaDB Corporation's MariaDB Package Repository by using the .

    You can also configure your package manager to install it from MariaDB Foundation's MariaDB Repository by using the .

    Installing with yum/dnf

    On RHEL, CentOS, Fedora, and other similar Linux distributions, it is highly recommended to install the relevant from MariaDB's repository using or . Starting with RHEL 8 and Fedora 22, yum has been replaced by dnf, which is the next major version of yum. However, yum commands still work on many systems that use dnf. For example:

    If you want to build applications with MariaDB Connector/C, then you will also need to install the development package. For example:

    Installing with apt-get

    On Debian, Ubuntu, and other similar Linux distributions, it is highly recommended to install the relevant from MariaDB's repository using . For example:

    If you want to build applications with MariaDB Connector/C, then you will also need to install the development package. For example:

    Installing with zypper

    On SLES, OpenSUSE, and other similar Linux distributions, it is highly recommended to install the relevant from MariaDB's repository using .

    For example:

    If you want to build applications with MariaDB Connector/C, then you will also need to install the development package. For example:

    hashtag
    Installing MariaDB Connector/C from Source

    See for information on how to build MariaDB Connector/C from source.

    hashtag
    API - Function Reference

    MariaDB Connector/C has exactly the same API as the MySQL Connector/C for MySQL 5.5

    The function reference is available at:

    It is also downloadable in html format from

    hashtag
    Configuring MariaDB Connector/C with Option Files

    Just like MariaDB Server and libmysqlclient, MariaDB Connector/C can also read configuration options from client in .

    See for more information.

    hashtag
    Known Bugs and Limitations

    • double to string conversion for prepared statements doesn't work correctly

    • Connector 3.0.7 and below doesn't support the MySQL 8.0 default authentication protocol, . This protocol should be supported in Connector/C 3.0.8 and above.

    hashtag
    Reporting Bugs

    If you find a bug, please report it via the on .

    hashtag
    Source Code

    The source code is available at the on GitHub.

    hashtag
    License

    GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

    For licensing questions, see the .

    MariaDB Connector/R2DBC Guide

    Quickstart guide for MariaDB Connector/R2DBC

    MariaDB Connector/R2DBC allows Java developers to connect to MariaDB and MySQL databases using the Reactive Relational Database Connectivity (R2DBC) API. This enables non-blocking, asynchronous database operations, which are beneficial for building scalable and responsive applications.

    hashtag
    1. Installation

    Add the necessary dependency to your project's pom.xml (Maven) or build.gradle (Gradle) file. Choose the dependency based on the R2DBC Specification you are targeting.

    Install MariaDB Connector/C

    Complete MariaDB installation guide. Complete setup instructions for Linux, Windows, and macOS with configuration and verification for production use.

    MariaDB Connector/C supports several Linux distributions and Microsoft Windows.

    hashtag
    Configure Package Repository (Linux)

    To install MariaDB Connector/C on Linux using APT, YUM, or ZYpp, you must configure your system to use either the ES Package Repository or the CS Package Repository.

    If your system is already configured to use one of these package repositories, you can skip to .

    /* get server port for current connection */
    unsigned int port;
    mariadb_get_infov(mysql, MARIADB_CONNECTION_PORT, void *)&port);
    /* get user name for current connection */
    const char *user;
    mariadb_get_infov(mysql, MARIADB_CONNECTION_USER, (void *)&user);
    uint8_t reconnect;
    
    rc = mysql_get_optionv(mysql, MYSQL_OPT_RECONNECT, &reconnect);
    uint32_t timeout;
    
    rc = mysql_get_optionv(mysql, MYSQL_OPT_CONNECT_TIMEOUT, &timeout);
    char *plugin_dir;
    
    rc = mysql_get_optionv(mysql, MYSQL_PLUGIN_DIR, &plugin_dir);
    char **commands;
    int elements;
    
    rc = mysql_get_optionv(mysql, MYSQL_INIT_COMMAND, &commands, &elements);
    /* get number of connection attributes */
    int i, elements= 0;
    char **key, **value;
    
    mysql_get_optionv(mysql, MYSQL_CONNECT_ATTRS, NULL, NULL, (void *)&elements);
    key= (char **)malloc(sizeof(char *) * elements);
    val= (char **)malloc(sizeof(char *) * elements);
    mysql_get_optionv(mysql, MYSQL_OPT_CONNECT_ATTRS, &key, &val, &elements);
    for (i=0; i < elements; i++)
      printf("key: %s value: %s", key[i], val[i]);
    const char *ssh_user;
    mysql_get_optionv(mysql, MARIADB_OPT_USERDATA, "ssh_user", (void *)ssh_user);
    <dependency>
        <groupId>org.mariadb.jdbc</groupId>
        <artifactId>mariadb-java-client</artifactId>
        <version>3.3.3</version> </dependency>
    dependencies {
        implementation 'org.mariadb.jdbc:mariadb-java-client:3.3.3' // Use the latest stable version
    }
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.sql.Statement;
    
    public class MariaDBQuickstart {
    
        // Database connection parameters
        static final String DB_URL = "jdbc:mariadb://localhost:3306/your_database_name";
        static final String USER = "your_username";
        static final String PASS = "your_password";
    
        public static void main(String[] args) {
            Connection conn = null;
            Statement stmt = null;
            ResultSet rs = null;
    
            try {
                // Register JDBC driver (optional for modern JDBC, but good practice)
                // Class.forName("org.mariadb.jdbc.Driver");
    
                System.out.println("Connecting to database...");
                conn = DriverManager.getConnection(DB_URL, USER, PASS);
    
                System.out.println("Creating statement...");
                stmt = conn.createStatement();
                String sql = "SELECT id, name FROM your_table_name";
                rs = stmt.executeQuery(sql);
    
                // Extract data from result set
                while (rs.next()) {
                    // Retrieve by column name
                    int id = rs.getInt("id");
                    String name = rs.getString("name");
    
                    // Display values
                    System.out.print("ID: " + id);
                    System.out.println(", Name: " + name);
                }
            } catch (SQLException se) {
                // Handle errors for JDBC
                se.printStackTrace();
            } finally {
                // Close resources in finally block
                try {
                    if (rs != null) rs.close();
                } catch (SQLException se2) {
                    // Do nothing
                }
                try {
                    if (stmt != null) stmt.close();
                } catch (SQLException se2) {
                    // Do nothing
                }
                try {
                    if (conn != null) conn.close();
                } catch (SQLException se) {
                    se.printStackTrace();
                }
                System.out.println("Database resources closed.");
            }
        }
    }
    Driver={MariaDB ODBC Driver};Server=localhost;Port=3306;Database=your_database_name;Uid=your_username;Pwd=your_password;
    cmake ../connector_c -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local
    cmake .. -D{PLUGIN_NAME}_PLUGIN_TYPE=[STATIC|DYNAMIC|OFF]
    cmake .. -DCLIENT_PLUGIN_{PLUGIN_NAME}=[STATIC|DYNAMIC|OFF]
    void mysql_debug(const char * debug);
    field_1:field_2:field_n
    flag[,modifier,modifier,...,modifier]
    sudo yum install MariaDB-shared
    sudo yum install MariaDB-devel
    sudo apt-get install libmariadb3
    sudo apt-get install libmariadb-dev
    sudo zypper install MariaDB-shared
    sudo zypper install MariaDB-devel
    spinner
    spinner
    spinner
    spinner
    spinner
    spinner
    spinner
    spinner
    spinner
    spinner
    spinner
    spinner
    spinner
    spinner
    spinner
    spinner
    spinner
    spinner
    spinner
    spinner
    spinner
    spinner
    spinner
    spinner
    spinner
    spinner
    spinner
    spinner
    spinner
    spinner
    spinner
    spinner
    spinner
    spinner
    spinner
    spinner
    spinner
    spinner
    spinner
    spinner
    spinner
    spinner
    spinner
    spinner
    spinner
    spinner
    spinner
    spinner
    spinner
    spinner
    spinner
    spinner
    spinner
    spinner
    spinner
    spinner
    spinner
    spinner
    spinner
    spinner

    DIALOG

    Authentication

    dynamic

    Authentication for user input, e.g. for PAM authentication

    OLDPASSWORD

    Authentication

    static

    Pre. 4.1 authentication (deprecated)

    NATIVE

    Authentication

    static

    Default authentication

    CLEARTEXT

    Authentication

    dynamic

    Sends password without hashing or encryption

    AUTH_GSSAPI

    Authentication

    dynamic

    Kerberos/GSSAPI authentication plugin

    SHA256_PASSWORD

    Authentication

    dynamic

    SHA256 password authentication plugin

    AURORA

    Connection

    OFF

    Fail over plugin for Aurora (experimental)

    REPLICATION

    Connection

    OFF

    Replication/fail over plugin (experimental)

    spinner
    is
    users
    with columns
    id
    ,
    name
    ,
    email
    . Adjust the table/column names as needed.
    to save changes or
    conn.rollback()
    to undo them.
  • Error Handling: Use try...except mariadb.Error blocks to gracefully handle database-related exceptions.

  • Resource Management: Always close your cursor and connection objects in a finally block to ensure resources are released, even if errors occur.

  • PyPI MariaDB Connector/Pythonarrow-up-right
    MariaDB Connector/Python Documentation (GitHub Pages)arrow-up-right
    MariaDB Developers Python Quickstart (GitHub)arrow-up-right

    Prepared Statements/Escaping: Never concatenate user-provided strings directly into SQL queries. Use prepared statements with placeholders (?) or client.escape() for string literals.

    rubygems.org/gems/mysql2arrow-up-right
    mysql2 gem on RubyGems.orgarrow-up-right
    mysql2 gem Documentation (Rubydoc.info)arrow-up-right
    Go to the "User DSN" or "System DSN" tab (System DSN is generally preferred for broader application access).
  • Click "Add...".

  • Select "MariaDB ODBC Driver" (or "MariaDB ODBC 3.1 Driver" depending on the version) from the list and click "Finish".

  • A configuration dialog will appear. Fill in the details:

    • Data Source Name: A descriptive name for your DSN (e.g., MyMariaDBDSN).

    • TCP/IP Server: localhost or the IP address/hostname of your MariaDB server.

    • Port: 3306 (default MariaDB port).

    • User: Your database username.

    • Password: Your database password.

    • Database: The specific database you want to connect to.

  • Click "Test" to verify the connection. Click "OK" to save the DSN.

  • You need to create or modify ~/.odbc.ini (for user DSNs) or /etc/odbc.ini (for system DSNs) to define your data source.

    Example odbcinst.ini (Driver Definition - usually installed automatically):

    Example odbc.ini (DSN Definition):

    a. For R2DBC 1.0.0 Specification (Recommended for new projects):

    XML

    Gradle

    b. For R2DBC 0.9.1 Specification (for compatibility):

    XML

    Gradle

    hashtag
    2. Basic Usage (Native R2DBC)

    This example demonstrates how to establish a connection, execute a query, and process results using the reactive API.

    Code snippet

    Before Running:

    1. Replace your_username, your_password, your_database_name, and your_table_name with your actual MariaDB server details.

    2. Ensure you have a MariaDB server running and a database/table set up.

    3. Add reactor-core dependency if not already present, as R2DBC heavily relies on Project Reactor.

    hashtag
    3. Connection Strings

    MariaDB Connector/R2DBC supports a standard R2DBC URL format for connection:

    r2dbc:mariadb://[username[:password]@]host[:port][/database][?option=value]

    Example:

    r2dbc:mariadb://user:pass@localhost:3306/mydb?useBatchMultiSend=true

    hashtag
    4. Spring Data R2DBC

    MariaDB Connector/R2DBC also integrates seamlessly with the Spring Data R2DBC framework, providing a higher-level abstraction for reactive database access, including repositories and entity mapping.

    hashtag
    Further Resources:

    • MariaDB Connector/R2DBC GitHub Repositoryarrow-up-right

    • R2DBC Specificationarrow-up-right

    • Spring Data R2DBC Documentationarrow-up-right

    This page is: Copyright © 2025 MariaDB. All rights reserved.

    spinner
    pip install mariadb
    # Or specifically for Python 3:
    # pip3 install mariadb
    import mariadb
    import sys
    
    # 1. Database Connection Parameters
    db_config = {
        'host': 'localhost',
        'port': 3306,
        'user': 'your_username',
        'password': 'your_password',
        'database': 'your_database_name'
    }
    
    def run_db_operations():
        conn = None
        cursor = None
        try:
            # 2. Establish a Connection
            print("Connecting to MariaDB...")
            conn = mariadb.connect(**db_config)
            print("Connection successful!")
    
            # 3. Create a Cursor Object
            cursor = conn.cursor()
    
            # --- Example: Create a Table (if it doesn't exist) ---
            try:
                cursor.execute("""
                    CREATE TABLE IF NOT EXISTS users (
                        id INT AUTO_INCREMENT PRIMARY KEY,
                        name VARCHAR(255) NOT NULL,
                        email VARCHAR(255) UNIQUE
                    )
                """)
                conn.commit() # Commit the transaction for DDL
                print("Table 'users' created or already exists.")
            except mariadb.Error as e:
                print(f"Error creating table: {e}")
                conn.rollback() # Rollback in case of DDL error
    
            # --- Example: Insert Data (Parameterized Query) ---
            print("\nInserting data...")
            insert_query = "INSERT INTO users (name, email) VALUES (?, ?)"
            try:
                cursor.execute(insert_query, ("Alice Wonderland", "alice@example.com"))
                cursor.execute(insert_query, ("Bob Builder", "bob@example.com"))
                conn.commit() # Commit the transaction for DML
                print(f"Inserted {cursor.rowcount} rows.")
                print(f"Last inserted ID: {cursor.lastrowid}")
            except mariadb.IntegrityError as e:
                print(f"Error inserting data (might be duplicate email): {e}")
                conn.rollback()
            except mariadb.Error as e:
                print(f"Error inserting data: {e}")
                conn.rollback()
    
            # --- Example: Select Data ---
            print("\nSelecting data...")
            select_query = "SELECT id, name, email FROM users WHERE name LIKE ?"
            cursor.execute(select_query, ("%Alice%",)) # Note the comma for single parameter tuple
            
            print("Fetched data:")
            for row in cursor:
                print(f"ID: {row[0]}, Name: {row[1]}, Email: {row[2]}")
    
            # --- Example: Update Data ---
            print("\nUpdating data...")
            update_query = "UPDATE users SET name = ? WHERE email = ?"
            cursor.execute(update_query, ("Alicia Wonderland", "alice@example.com"))
            conn.commit()
            print(f"Rows updated: {cursor.rowcount}")
    
            # --- Example: Delete Data ---
            print("\nDeleting data...")
            delete_query = "DELETE FROM users WHERE name = ?"
            cursor.execute(delete_query, ("Bob Builder",))
            conn.commit()
            print(f"Rows deleted: {cursor.rowcount}")
    
        except mariadb.Error as e:
            print(f"An error occurred: {e}")
            sys.exit(1)
        finally:
            # 4. Close Cursor and Connection
            if cursor:
                cursor.close()
                print("Cursor closed.")
            if conn:
                conn.close()
                print("Connection closed.")
    
    if __name__ == "__main__":
        run_db_operations()
    sudo apt update
    sudo apt install libmariadb-dev # Or libmysqlclient-dev
    # If using Bundler (e.g., in a Rails project's Gemfile)
    # Gemfile
    # gem 'mysql2'
    bundle install
    
    # Or directly
    gem install mysql2
    require 'mysql2'
    
    begin
      client = Mysql2::Client.new(
        host: 'localhost',
        port: 3306,
        username: 'your_username',
        password: 'your_password',
        database: 'your_database_name'
      )
      puts "Successfully connected to MariaDB!"
    
      # ... database operations ...
    
    rescue Mysql2::Error => e
      puts "Error connecting to database: #{e.message}"
    ensure
      client&.close # Ensure the connection is closed
    end
    # Assuming 'client' is an open connection
    results = client.query("SELECT id, name FROM your_table_name WHERE status = 'active'")
    
    puts "\nSelected Rows:"
    results.each do |row|
      puts "ID: #{row['id']}, Name: #{row['name']}"
    end
    # INSERT Example (using prepared statement)
    statement = client.prepare("INSERT INTO your_table_name (name, status) VALUES (?, ?)")
    insert_result = statement.execute("New Item", "pending")
    puts "\nRows inserted: #{insert_result.affected_rows}, Last ID: #{insert_result.last_id}"
    
    # UPDATE Example
    update_result = client.query("UPDATE your_table_name SET status = 'completed' WHERE name = 'New Item'")
    puts "Rows updated: #{update_result.affected_rows}"
    
    # DELETE Example
    delete_result = client.query("DELETE FROM your_table_name WHERE name = 'New Item'")
    puts "Rows deleted: #{delete_result.affected_rows}"
    # Assuming 'client' is an open connection
    statement = client.prepare("SELECT * FROM users WHERE login_count = ?")
    
    # Execute with different parameters
    result1 = statement.execute(1)
    puts "\nUsers with login_count = 1:"
    result1.each { |row| puts row.inspect }
    
    result2 = statement.execute(5)
    puts "\nUsers with login_count = 5:"
    result2.each { |row| puts row.inspect }
    isql MyMariaDBDSN your_username your_password
    [MariaDB ODBC Driver]
    Description = MariaDB Connector/ODBC
    Driver = /usr/lib/x86_64-linux-gnu/odbc/libmaodbc.so # Adjust path for your system
    Setup = /usr/lib/x86_64-linux-gnu/odbc/libmaodbc.so # Adjust path for your system
    UsageCount = 1
    FileUsage = 1
    CPTimeout =
    CPReconnect =
    [MyMariaDBDSN]
    Description = My MariaDB Database
    Driver = MariaDB ODBC Driver # Matches the name from odbcinst.ini
    SERVER = localhost
    PORT = 3306
    DATABASE = your_database_name
    UID = your_username
    PASSWORD = your_password
    OPTION =
    <dependency>
        <groupId>org.mariadb</groupId>
        <artifactId>r2dbc-mariadb</artifactId>
        <version>1.2.x</version> </dependency>
    // Gradle
    implementation 'org.mariadb:r2dbc-mariadb:1.2.x' // Use the latest stable version
    <dependency>
        <groupId>org.mariadb</groupId>
        <artifactId>r2dbc-mariadb-0.9.1-spec</artifactId>
        <version>1.2.x</version> </dependency>
    // Gradle
    implementation 'org.mariadb:r2dbc-mariadb-0.9.1-spec:1.2.x' // Use the latest stable version
    import io.r2dbc.spi.ConnectionFactories;
    import io.r2dbc.spi.ConnectionFactory;
    import io.r2dbc.spi.ConnectionFactoryOptions;
    import io.r2dbc.spi.Connection;
    import io.r2dbc.spi.Result;
    import reactor.core.publisher.Flux;
    import reactor.core.publisher.Mono;
    
    import static io.r2dbc.spi.ConnectionFactoryOptions.DATABASE;
    import static io.r2dbc.spi.ConnectionFactoryOptions.DRIVER;
    import static io.r2dbc.spi.ConnectionFactoryOptions.HOST;
    import static io.r2dbc.spi.ConnectionFactoryOptions.PASSWORD;
    import static io.r2dbc.spi.ConnectionFactoryOptions.PORT;
    import static io.r2dbc.spi.ConnectionFactoryOptions.USER;
    import org.mariadb.r2dbc.MariadbConnectionConfiguration;
    import org.mariadb.r2dbc.MariadbConnectionFactory;
    
    public class MariaDBR2DBCQuickstart {
    
        public static void main(String[] args) {
            // Option 1: Using ConnectionFactoryOptions Builder (Recommended for explicit configuration)
            MariadbConnectionConfiguration conf = MariadbConnectionConfiguration.builder()
                    .host("localhost")
                    .port(3306)
                    .username("your_username")
                    .password("your_password")
                    .database("your_database_name")
                    .build();
            ConnectionFactory factory = new MariadbConnectionFactory(conf);
    
            // Option 2: Using a R2DBC Connection URL
            // ConnectionFactory factory = ConnectionFactories.get("r2dbc:mariadb://your_username:your_password@localhost:3306/your_database_name");
    
            Mono<Connection> connectionMono = Mono.from(factory.create());
    
            // --- Example: Select Data ---
            connectionMono
                .flatMapMany(connection ->
                    Flux.from(connection.createStatement("SELECT id, name FROM your_table_name WHERE status = ?")
                                       .bind(0, "active") // Bind parameter by index
                                       .execute())
                        .flatMap(result -> result.map((row, rowMetadata) -> {
                            int id = row.get("id", Integer.class);
                            String name = row.get("name", String.class);
                            return "ID: " + id + ", Name: " + name;
                        }))
                        .doFinally(signalType -> Mono.from(connection.close()).subscribe()) // Close connection when done
                )
                .doOnNext(System.out::println) // Print each row
                .doOnError(Throwable::printStackTrace) // Handle errors
                .blockLast(); // Block to ensure the main thread waits for completion (for quickstart example)
    
    
            // --- Example: Insert Data ---
            connectionMono
                .flatMap(connection ->
                    Mono.from(connection.createStatement("INSERT INTO your_table_name (name, status) VALUES (?, ?)")
                                       .bind(0, "New Item")
                                       .bind(1, "pending")
                                       .execute())
                        .flatMap(Result::getRowsUpdated) // Get number of affected rows
                        .doFinally(signalType -> Mono.from(connection.close()).subscribe()) // Close connection
                )
                .doOnNext(rowsUpdated -> System.out.println("Rows inserted: " + rowsUpdated))
                .doOnError(Throwable::printStackTrace)
                .block(); // Block for simplicity in quickstart
    
    
            System.out.println("MariaDB R2DBC operations completed.");
        }
    }
    Choose a package repository to configure:

    Package Repository

    Description

    • MariaDB Enterprise Server package repository

    • Available to customers of MariaDB Corporation

    • Available for APT, YUM, and ZYpp on supported Linux distributions

    • MariaDB Community Server package repository

    • Publicly available

    • Available for APT, YUM, and ZYpp on supported Linux distributions

    hashtag
    ES Package Repository

    MariaDB Connector/C is available from the same package repository as MariaDB Enterprise Server.

    To configure the ES package repository:

    1. Install curl.

      Install via APT on Debian, Ubuntu:

      Install via YUM on CentOS, RHEL, Rocky Linux:

      Install via ZYpp on SLES:

    2. Download the utility, validate its checksum, and ensure that its permissions allow it to be executed:

      1. Checksums of the various releases of the mariadb_es_repo_setup script can be found in the section at the bottom of the page. Subsitute ${checksum} in the example above with the latest checksum.

    3. Retrieve your Customer Download Token at and substitute your token for CUSTOMER_DOWNLOAD_TOKEN in the following step.

    4. Configure the ES package repository using the utility:

      • All major releases of ES contain the same version of MariaDB Connector/C.

      • By default, the utility will configure your system to use the package repository for ES 10.6.

    5. using the package repository.

    hashtag
    CS Package Repository

    MariaDB Connector/C is available from the same package repository as MariaDB Community Server.

    To configure the CS package repository:

    1. Install curl.

      Install via APT on Debian, Ubuntu:

      Install via YUM on CentOS, RHEL, Rocky Linux:

      Install via ZYpp on SLES:

    2. Download the utility, validate its checksum, and ensure that its permissions allow it to be executed:

      1. Checksums of the various releases of the mariadb_repo_setup script can be found in the section at the bottom of the page. Subsitute ${checksum} in the example above with the latest checksum.

    3. Configure the CS package repository using the utility:

      • All major releases of CS contain the same version of MariaDB Connector/C.

      • By default, the utility will configure your system to use the package repository for CS 10.6.

    4. using the package repository.

    hashtag
    Installation

    hashtag
    Installation via Package Repository (Linux)

    On supported Linux distributions, MariaDB Connector/C can be installed using APT, YUM, or ZYpp if the system is configured to use the ES Package Repository or the CS Package Repository.

    hashtag
    Install on CentOS, RHEL, Rocky Linux

    To install MariaDB Connector/C on CentOS, RHEL, and Rocky Linux, you can use YUM if you have the ES Package Repository or CS Package Repository configured.

    Install MariaDB Connector/C and package dependencies:

    hashtag
    Install on Debian, Ubuntu

    To install MariaDB Connector/C on Debian and Ubuntu, you can use APT if you have the ES Package Repository or CS Package Repository configured.

    Install MariaDB Connector/C and package dependencies:

    hashtag
    Install on SLES

    To install MariaDB Connector/C on SLES, you can use ZYpp if you have the ES Package Repository or CS Package Repository configured.

    Install MariaDB Connector/C and package dependencies:

    hashtag
    Install via Binary Tarball (Linux)

    MariaDB Connector/C can be installed on supported Linux distributions via a binary tarball package:

    1. Go to the MariaDB Connector/C download pagearrow-up-right

    2. Ensure the "Product" dropdown reads "C connector."

    3. In the "Version" dropdown, select the version you want to download.

    4. In the "OS" dropdown, select your Linux distribution.

    5. Click on the "Download" button to download the binary tarball package.

    hashtag
    Install via MSI (Windows)

    MariaDB Connector/C can be installed on Microsoft Windows via an MSI package:

    1. Go to the MariaDB Connector/C download pagearrow-up-right

    2. Ensure the "Product" dropdown reads "C connector."

    3. In the "Version" dropdown, select the version you want to download.

    4. In the "OS" dropdown, select either "MS Windows (64-bit)" or "MS Windows (32-bit)", depending on whether you need a 64-bit or 32-bit connector.

    5. Click on the "Download" button to download the MSI package.

    6. When the MSI package finishes downloading, run it and follow the on-screen instructions.

    This page is: Copyright © 2025 MariaDB. All rights reserved.

    install MariaDB Connector/C
    spinner

    L

    Identify the source file line number for each line of debug or trace output.

    n

    Print the current function nesting depth for each line of debug or trace output.

    N

    Number each line of dbug output.

    o

    Redirect the debugger output stream to the specified file. The default output is stderr.

    O

    As o but the file is really flushed between each write. When needed the file is closed and reopened between each write.

    a

    Like o, but opens for append.

    A

    Like O, but opens for append.

    p

    Limit debugger actions to specified processes. A process must be identified with the DBUG_PROCESS macro and match one in the list for debugger actions to occur.

    P

    Print the current process name for each line of debug or trace output.

    r

    When pushing a new state, do not inherit the previous state's function nesting level. Useful when the output is to start at the left margin.

    S

    Do function _sanity(file,line) at each debugged function until _sanity() returns something that differs from 0. (Mostly used with safemalloc)

    t

    Enable function call/exit trace lines. May be followed by a list (containing only one modifier) giving a numeric maximum trace level, beyond which no output will occur for either debugging or tracing macros. The default is a compile time option.

    spinner
    MariaDB Connector/C
    Download Now
    MDEV-9055arrow-up-right
    #connectorsarrow-up-right
    MariaDB Repository Configuration Toolarrow-up-right
    apt-getarrow-up-right
    Building Connector/C From Source
    MariaDB Client Library for C API Functions
    MariaDB Client Library for C API Prepared Statement Functions
    mariadb-client-doc.ziparrow-up-right
    Configuring MariaDB Connector/C with Option Files
    caching_sha2_passwordarrow-up-right
    CONC projectarrow-up-right
    MariaDB's Jira bug trackerarrow-up-right
    mariadb-connector-c repositoryarrow-up-right
    spinner

    mysql_set_character_set

    hashtag
    Syntax

    • mysql - a mysql handle, which was previously allocated by mysql_init() or mysql_real_connect().

    • csname - character set name

    hashtag
    Description

    Sets the default for the current connection. Returns zero on success, non-zero on failure.

    circle-info

    It's strongly recommended to use mysql_set_character_set() instead of SET NAMES ... since might fail or deliver unexpected results.

    The client library supports the following character sets:

    Character set
    Description

    hashtag
    See also

    spinner
    spinner
    spinner
    spinner
    spinner
    spinner
    spinner
    spinner
    spinner
    spinner
    spinner
    spinner
    spinner
    spinner
    spinner
    spinner
    spinner
    spinner
    sudo apt install curl
    sudo yum install curl
    sudo zypper install curl
    $ curl -LsSO https://dlm.mariadb.com/enterprise-release-helpers/mariadb_es_repo_setup
    $ echo "${checksum}  mariadb_es_repo_setup" \
        | sha256sum -c -
    $ chmod +x mariadb_es_repo_setup
    $ sudo apt install curl
    $ sudo yum install curl
    $ sudo zypper install curl
    curl -LsSO https://r.mariadb.com/downloads/mariadb_repo_setup
    echo "${checksum} mariadb_repo_setup" \
        | sha256sum -c -
    chmod +x mariadb_repo_setup
    sudo yum install MariaDB-shared MariaDB-devel
    sudo apt install libmariadb3 libmariadb-dev
    sudo zypper install MariaDB-shared MariaDB-devel
    sudo yum install MariaDB-shared
    sudo yum install MariaDB-devel
    sudo apt-get install libmariadb3
    sudo apt-get install libmariadb-dev
    sudo zypper install MariaDB-shared
    sudo zypper install MariaDB-devel
    int mysql_set_character_set(MYSQL * mysql,
                                const char * csname);
    To configure your system to use the ES package repository for a specific major release, use the option.
    To configure your system to use the CS package repository for a specific major release, use the option.
    Configured with the utility
    Configured with the utility
    Customer Download Token at the MariaDB Customer Portalarrow-up-right
    mariadb_es_repo_setuparrow-up-right
    Install MariaDB Connector/C
    mariadb_repo_setuparrow-up-right
    Install MariaDB Connector/C
    ES Package Repository
    CS Package Repository

    cp1256

    Windows code page 1256-character set

    cp1257

    Windows code page 1257-character set

    cp850

    MS-DOS Codepage 850 (Western Europe)

    cp852

    MS-DOS Codepage 852 (Middle Europe)

    cp866

    MS-DOS Codepage 866 (Russian)

    cp932

    Microsoft Codepage 932 (Extension to sjis)

    dec8

    DEC West European

    eucjpms

    UJIS for Windows Japanese

    euckr

    EUC KR-Korean

    gb2312

    GB-2312 simplified Chinese

    gbk

    GBK simplified Chinese

    geostd8

    GEOSTD8 Georgian

    greek

    ISO 8859-7 Greek

    hebrew

    ISO 8859-8 Hebrew

    hp8

    HP West European

    keybcs2

    DOS Kamenicky Czech-Slovak

    koi8r

    KOI8-R Relcom Russian

    koi8u

    KOI8-U Ukrainian

    latin1

    CP1252 Western European

    latin2

    ISO 8859-2 Central Europe

    latin5

    ISO 8859-9 Turkish

    latin7

    ISO 8859-13 Baltic

    macce

    MAC Central European

    macroman

    MAC Western European

    sjis

    SJIS for Windows Japanese

    swe7

    7-bit Swedish

    tis620

    TIS620 Thai

    ucs2

    UCS-2 Unicode

    ujis

    EUC-JP Japanese

    utf8

    UTF-8 Unicode

    utf16

    UTF-16 Unicode

    utf32

    UTF-32 Unicode

    utf8mb4

    UTF 4-byte Unicode

    armscii8

    8-bit character set for Armenian

    ascii

    US ASCII character set

    big5

    2-byte character set for traditional Chinese, Hongkong, Macau and Taiwan

    binary

    8-bit binary character set

    cp1250

    Windows code page 1250-character set

    cp1251

    Windows code page 1251-character set

    mysql_real_escape_string()
    mysql_real_escape_string()
    spinner

    Connector/Node.js Guide

    Quickstart guide for MariaDB Connector/Node.js

    hashtag
    Quickstart Guide: MariaDB Connector/Node.js

    MariaDB Connector/Node.js is a client library that enables Node.js applications to connect and interact with MariaDB and MySQL databases. It's built natively in JavaScript and supports both Promise and Callback APIs, with the Promise API being the default and recommended approach. It is licensed under the LGPL.

    hashtag
    1. Installation

    The easiest way to install MariaDB Connector/Node.js is using npm (Node Package Manager):

    hashtag
    2. Basic Usage (Promise API - Recommended)

    The Promise API simplifies asynchronous operations with async/await. For optimal performance and resource management, it's recommended to use a connection pool.

    a. Create a Connection Pool:

    Replace localhost, 3306, your_username, your_password, and your_database_name with your actual database details.

    b. Perform Database Operations:

    Here's an async function example to get a connection, execute queries, and release the connection back to the pool.

    hashtag
    3. Basic Usage (Callback API - for Compatibility)

    If you need compatibility with older Node.js database drivers (mysql, mysql2), you can use the Callback API.

    hashtag
    Important Notes:

    • Error Handling: Always include robust error handling (try...catch for Promises, if (err) for Callbacks) in your database interactions.

    • Parameterized Queries: Always use parameterized queries (e.g., WHERE status = ?, VALUES (?, ?)) to prevent SQL injection attacks.

    hashtag
    Further Resources:

    MariaDB Connector/C Data Structures

    This page describes the public data structures used by MariaDB Connector/C.

    hashtag
    MYSQL

    The MYSQL structure represents one database connection and is used by most of MariaDB Connector/C's API functions. The MYSQL structure needs to be allocated and initialized by the API function. It will be released by the function.

    sudo ./mariadb_es_repo_setup --token="CUSTOMER_DOWNLOAD_TOKEN" --apply \
       --mariadb-server-version="10.6"
    sudo ./mariadb_repo_setup \
       --mariadb-server-version="mariadb-10.6"

    Connection Pooling: For production applications, always use a connection pool (mariadb.createPool()) instead of single connections to manage resources efficiently.

  • conn.release() vs. conn.end(): When using a pool, use conn.release() to return the connection to the pool. Use conn.end() or pool.end() only when gracefully shutting down your application.

  • MariaDB Connector/Node.js GitHub Repositoryarrow-up-right
    MariaDB Connector/Node.js Documentation
    npm mariadb package pagearrow-up-right
    npm install mariadb
    const mariadb = require('mariadb');
    const pool = mariadb.createPool({
        host: 'localhost',
        port: 3306,
        user: 'your_username',
        password: 'your_password',
        database: 'your_database_name',
        connectionLimit: 5 // Adjust as needed
    });
    
    console.log("Connection pool created.");
    async function executeDatabaseOperations() {
        let conn;
        try {
            conn = await pool.getConnection(); // Get a connection from the pool
    
            // --- SELECT Query ---
            const rows = await conn.query("SELECT id, name FROM your_table_name WHERE status = ?", ["active"]);
            console.log("Selected Rows:", rows);
    
            // --- INSERT Query (with parameters for security) ---
            const res = await conn.query("INSERT INTO your_table_name (name, status) VALUES (?, ?)", ["New Entry", "pending"]);
            console.log("Insert Result:", res); // res will contain { affectedRows: 1, insertId: ..., warningStatus: 0 }
    
        } catch (err) {
            console.error("Database operation error:", err);
            throw err; // Re-throw to handle higher up
        } finally {
            if (conn) {
                conn.release(); // Release connection back to the pool
                console.log("Connection released to pool.");
            }
        }
    }
    
    // Call the async function
    executeDatabaseOperations()
        .then(() => console.log("All database operations attempted."))
        .catch((err) => console.error("Overall operation failed:", err))
        .finally(() => {
            // Optional: End the pool when your application is shutting down
            // pool.end();
            // console.log("Connection pool ended.");
        });
    const mariadb = require('mariadb/callback');
    
    // Create a single connection
    mariadb.createConnection({
        host: 'localhost',
        port: 3306,
        user: 'your_username',
        password: 'your_password',
        database: 'your_database_name'
    }, (err, conn) => {
        if (err) {
            console.error("Connection error:", err);
            return;
        }
    
        console.log("Connected using Callback API.");
    
        // Execute a query
        conn.query("SELECT 1 AS val", (queryErr, rows) => {
            if (queryErr) {
                console.error("Query error:", queryErr);
                conn.end(); // Close connection on error
                return;
            }
            console.log("Query Result (Callback):", rows);
    
            // Close the connection when done
            conn.end((endErr) => {
                if (endErr) {
                    console.error("Error closing connection:", endErr);
                } else {
                    console.log("Connection closed (Callback).");
                }
            });
        });
    });
    circle-info

    The MYSQL structure should be considered as opaque; copying or changing values of its members might produce unexpected results, errors or program crashes.

    hashtag
    MYSQL_RES

    The MYSQL_RES structure represents a result set which contains data and metadata information. It will be returned by the mysql_use_result(), mysql_store_result() and mysql_stmt_result_metadata() API functions and needs to be released by mysql_free_result().

    circle-info

    The MYSQL_RES structure should be considered as opaque; copying or changing values of its members might produce unexpected results, errors or program crashes.

    hashtag
    MYSQL_ROW

    MYSQL_ROW represents an array of character pointers, pointing to the columns of the actual data row. Data will be received by the mysql_fetch_row() function. The size of the array is the number of columns for the current row.

    circle-info

    After freeing the result set with mysql_free_result() MYSQL_ROW becomes invalid.

    hashtag
    MYSQL_STMT

    The MYSQL_STMT structure represents a prepared statement handle and is used by MariaDB Connector/C's prepared statement API functions. The MYSQL_STMT structure needs to be allocated and initialized by the mysql_stmt_init() function and needs to be released by the mysql_stmt_close() function.

    circle-info

    The MYSQL_STMT structure should be considered as opaque; copying or changing values of its members might produce unexpected results, errors or program crashes.

    hashtag
    MYSQL_FIELD

    The MYSQL_FIELD structure describes the metadata of a column. It can be obtained by the mysql_fetch_field() function.

    It has the following members:

    char *

    name

    The name of the column

    unsigned int

    name_length

    The length of column name

    char *

    org_name

    The original name of the column

    unsigned int

    org_name_length

    The length of original column name

    char *

    table

    The name of the table

    hashtag
    MYSQL_BIND

    The MYSQL_BIND structure is used to provide parameters for prepared statements or to receive output column value from prepared statements.

    unsigned long *

    length

    Pointer for the length of the buffer (not used for parameters). The length is ignored for numeric and fixed size data types, as the buffer_type value determines the size of the data.

    my_bool *

    is_nulll

    Pointer which indicates if column is NULL (not used for parameters)

    my_bool *

    error

    Pointer which indicates if an error occured

    void *

    buffer

    Data buffer which contains or receives data

    char *

    u.indicator

    Array of indicator variables for bulk operation parameter

    hashtag
    MYSQL_TIME

    The MYSQL_TIME structure is used for date and time values in prepared statements. It has the following members:

    unsigned int

    year

    Year

    unsigned int

    month

    Month

    unsigned int

    day

    Day

    unsigned int

    hour

    Hour

    unsigned int

    minute

    Minute

    mysql_init()
    mysql_close()
    spinner

    MariaDB Connector/C Types and Definitions

    MariaDB Connector/C provides the following types and definitions.

    hashtag
    Enumeration Types

    hashtag
    enum mysql_option

    unsigned int

    table_length

    The length of table name

    char *

    org_table

    The original name of the table

    unsigned int

    org_table_length

    The length of original table name

    char *

    db

    The name of the database (schema)

    unsigned int

    db_length

    The length of database name

    char *

    catalog

    The catalog name (always 'def')

    unsigned int

    catalog_length

    The length of catalog name

    char *

    def

    default value

    unsigned int

    def_length

    The length of default value

    unsigned int

    length

    The length (width) of the column definition

    unsigned int

    max_length

    The maximum length of the column value

    unsigned int

    flags

    Flags

    unsigned int

    decimals

    Number of decimals

    enum enum_field_types

    type

    Field type

    unsigned long

    buffer_length

    Length of buffer

    enum enum_field_types

    buffer_type

    Buffer type

    unsigned long

    length_value

    Used if length pointer is NULL

    my_bool

    error_value

    Used if error pointer is NULL

    my_bool

    is_null_value

    Used if is_null pointer is NULL

    my_bool

    is_unsigned

    Set if integer type is unsigned

    my_bool

    is_null_value

    Used if value is NULL

    unsigned int

    second

    Second

    unsigned long

    second_part

    Fractional seconds (max. 6 digits)

    my_bool

    neg

    Negative value

    enum enum_mysql_timestamp_type

    time_type

    Type

    enum mysql_option is used as a parameter in mysql_optionsv() and mysql_get_optionsv() API functions. For a list of integral constants and their meanings, please check the documentation of mysql_get_optionsv().

    hashtag
    enum enum_mysql_timestamp_type

    enum enum_mysql_timestamp_type is used in the MYSQL_TIME structure and indicates the type. It has the following constants:

    • MYSQL_TIMESTAMP_NONE

    • MYSQL_TIMESTAMP_ERROR

    • MYSQL_TIMESTAMP_DATE

    • MYSQL_TIMESTAMP_DATETIME

    • MYSQL_TIMESTAMP_TIME

    hashtag
    enum mysql_set_option

    enum mysql_set_option is used as a parameter in mysql_set_server_option() and has the following constants:

    • MYSQL_OPTIONS_MULTI_STATEMENTS_ON

    • MYSQL_OPTIONS_MULTI_STATEMENTS_OFF

    hashtag
    enum enum_field_types

    enum field_types describes the different field types used by MariaDB and has the following constants:

    • MYSQL_TYPE_DECIMAL

    • MYSQL_TYPE_TINY

    • MYSQL_TYPE_SHORT

    • MYSQL_TYPE_LONG

    • MYSQL_TYPE_FLOAT

    • MYSQL_TYPE_DOUBLE

    • MYSQL_TYPE_NULL

    • MYSQL_TYPE_TIMESTAMP

    • MYSQL_TYPE_LONGLONG

    • MYSQL_TYPE_INT24

    • MYSQL_TYPE_DATE

    • MYSQL_TYPE_TIME

    • MYSQL_TYPE_DATETIME

    • MYSQL_TYPE_YEAR

    • MYSQL_TYPE_NEWDATE

    • MYSQL_TYPE_VARCHAR

    • MYSQL_TYPE_BIT

    • MYSQL_TYPE_TIMESTAMP2

    • MYSQL_TYPE_DATETIME2

    • MYSQL_TYPE_TIME2

    • MYSQL_TYPE_JSON

    • MYSQL_TYPE_NEWDECIMAL

    • MYSQL_TYPE_ENUM

    • MYSQL_TYPE_SET

    • MYSQL_TYPE_TINY_BLOB

    • MYSQL_TYPE_MEDIUM_BLOB

    • MYSQL_TYPE_LONG_BLOB

    • MYSQL_TYPE_BLOB

    • MYSQL_TYPE_VAR_STRING

    • MYSQL_TYPE_STRING

    • MYSQL_TYPE_GEOMETRY

    hashtag
    enum mysql_enum_shutdown_level

    enum mysql_enum_shutdown_level is used as a parameter in mysql_server_shutdown() and has the following constants:

    • SHUTDOWN_DEFAULT

    • KILL_QUERY

    • KILL_CONNECTION

    hashtag
    enum enum_stmt_attr_type

    enum_stmt_attr_type is used to set different statement options. For a detailed description please check mysql_stmt_attr_set() function.

    hashtag
    enum enum_cursor_type

    enum_cursor_type specifies the cursor type and is used in mysql_stmt_attr_set() function. Currently the following constants are supported:

    • CURSOR_TYPE_READ_ONLY

    • CURSOR_TYPE_NO_CURSOR

    hashtag
    enum enum_indicator_type

    enum_indicator_type describes the type of indicator used for prepared statements bulk operations.

    STMT_INDICATOR_NTS

    String is zero terminated

    STMT_INDICATOR_NONE

    No indicator in use

    STMT_INDICATOR_NULL

    Value is NULL

    STMT_INDICATOR_DEFAULT

    Use default value

    STMT_INDICATOR_IGNORE

    Ignore the specified value

    STMT_INDICATOR_IGNORE_ROW

    Skip the current row

    hashtag
    Definitions

    hashtag
    Field Flags

    The following field flags are used in MYSQL_FIELD structure.

    Flag

    Value

    Description

    NOT_NULL_FLAG

    1

    Field can't be NULL

    PRI_KEY_FLAG

    2

    Field is part of primary key

    UNIQUE_KEY_FLAG

    4

    Field is part of unique key

    MULTIPLE_KEY_FLAG

    8

    Field is part of a key

    hashtag
    Server Status

    The server_status can be obtained by the mariadb_get_infov() function using the MARIADB_CONNECTION_SERVER_STATUS option.

    SERVER_STATUS_IN_TRANS

    1

    A transaction is currently active

    SERVER_STATUS_AUTOCOMMIT

    2

    Autocommit mode is set

    SERVER_MORE_RESULTS_EXISTS

    8

    more results exists (more packet follow)

    SERVER_QUERY_NO_GOOD_INDEX_USED

    16

    SERVER_QUERY_NO_INDEX_USED

    32

    hashtag
    Macros

    IS_PRI_KEY(flag)

    True if the field is part of a primary key

    IS_NOT_NULL(flags)

    True if the field is defined as not NULL

    IS_BLOB(flags)

    True if the field is a text or blob field

    IS_NUM(column_type)

    True if the column type is numeric

    IS_LONGDATA(column_type)

    True if the column is a blob or text field

    spinner

    BLOB_FLAG

    16

    Field is a blob

    UNSIGNED_FLAG

    32

    Field is unsigned integer

    ZEROFILL_FLAG

    64

    Field is zero filled

    BINARY_FLAG

    128

    Field is binary

    ENUM_FLAG

    256

    Field is enum

    AUTO_INCREMENT_FLAG

    512

    Field is an autoincrement field

    TIMESTAMP_FLAG

    1024

    Field is a timestamp

    SET_FLAG

    2048

    Field is a set

    NO_DEFAULT_VALUE_FLAG

    4096

    Field has no default value

    ON_UPDATE_NOW_FLAG

    8192

    If a field is updated it will get the current time value (NOW())

    NUM_FLAG

    32768

    Field is numeric

    SERVER_STATUS_CURSOR_EXISTS

    64

    when using COM_STMT_FETCH, indicate that current cursor still has result

    SERVER_STATUS_LAST_ROW_SENT

    128

    when using COM_STMT_FETCH, indicate that current cursor has finished to send results

    SERVER_STATUS_DB_DROPPED

    1<<8

    database has been dropped

    SERVER_STATUS_NO_BACKSLASH_ESCAPES

    1<<9

    current escape mode is "no backslash escape"

    SERVER_STATUS_METADATA_CHANGED

    1<<10

    A DDL change did have an impact on an existing PREPARE (an automatic reprepare has been executed)

    SERVER_QUERY_WAS_SLOW

    1<<11

    Last statement took more than the time value specified in server variable long_query_time.

    SERVER_PS_OUT_PARAMS

    1<<12

    this resultset contain stored procedure output parameter

    SERVER_STATUS_IN_TRANS_READONLY

    1<<13

    current transaction is a read-only transaction

    SERVER_SESSION_STATE_CHANGED

    1<<14

    session state change. see Session change type for more information

    mysql_optionsv

    hashtag
    Syntax

    • mysql - a mysql handle, which was previously allocated by mysql_init() or mysql_real_connect().

    • mysql_option - the option to set. See description below.

    • arg - the value for the option.

    • ... - variable argument list.

    hashtag
    Description

    Used to set extra connect options and affect behavior for a connection. This function may be called multiple times to set several options. All calls pass numeric literal values for a const void *. mysql_optionsv() should be called after .

    Some of these options can also be set in , such as my.cnf.

    hashtag
    Returns

    Returns zero on success, non-zero if an error occurred (invalid option or value).

    hashtag
    Options

    • MYSQL_INIT_COMMAND: lets you specify a command to execute immediately after connecting (and also after a reconnect if enabled).

      • Each call adds one SQL statement to an internal list; all stored commands are executed in order.

      • You cannot concatenate multiple statements with semicolons; each statement must be added with a separate call.

    hashtag
    Connection Options

    Some of these options can also be set as arguments to the function.

    • MARIADB_OPT_HOST: Hostname or IP address of the server to connect to.

    • MARIADB_OPT_USER: User to login to the server.

    • MARIADB_OPT_PASSWORD: Password of the user to login to the server.

    hashtag
    TLS Options

    • MYSQL_OPT_SSL_KEY: Defines a path to a private key file to use for . This option requires that you use the absolute path, not a relative path. If the key is protected with a passphrase, the passphrase needs to be specified with MARIADB_OPT_TLS_PASSPHRASE option.

    • MYSQL_OPT_SSL_CERT: Defines a path to the X509 certificate file to use for . This option requires that you use the absolute path, not a relative path.

    hashtag
    Plugin Options

    • MYSQL_DEFAULT_AUTH: Default authentication client-side plugin to use.

    • MYSQL_ENABLE_CLEARTEXT_PLUGIN: This option is supported to be compatible with MySQL client libraries. MySQL client libraries use this option to determine whether the authentication plugin can be used. However, MariaDB clients and client libraries do not need to set any options in order to use this authentication plugin. Therefore, this option does not actually do anything in MariaDB Connector/C.

    hashtag
    Option File Options

    • MYSQL_READ_DEFAULT_FILE: Read options from an .

    • MYSQL_READ_DEFAULT_GROUP: Read options from the named from an .

    These options work together, according to the following rules:

    • if both are set to NULL, then no option files are read.

    • if MYSQL_READ_DEFAULT_FILE is set to an empty string (or NULL and MYSQL_READ_DEFAULT_GROUP is set) then all are read.

    hashtag
    Connection Attribute Options

    Connection attributes are stored in the and Performance Schema tables. By default, MariaDB Connector/C sends the following connection attributes to the server:

    • _client_name: always "libmariadb"

    • _client_version: version of MariaDB Connector/C

    • _os: operation system

    circle-info

    If the is disabled, connection attributes will not be stored on server.

    • MYSQL_OPT_CONNECT_ATTR_DELETE: Deletes a connection attribute for the given key.

    • MYSQL_OPT_CONNECT_ATTR_ADD: Adds a key/value pair to connection attributes.

    • MYSQL_OPT_CONNECT_ATTR_RESET: Clears the current list of connection attributes.

    hashtag
    See Also

    int mysql_optionsv(MYSQL * mysql,
                       enum mysql_option,
                       const void * arg,
                       ...);

    MYSQL_OPT_CONNECT_TIMEOUT: Connect timeout in seconds. This value will be passed as an unsigned int parameter.

  • MARIADB_OPT_VERIFY_LOCAL_INFILE_CALLBACK: Specifies a callback function for filename and/or directory verification. This option was added in Connector/C 2.3.0

  • MYSQL_PROGRESS_CALLBACK: Specifies a callback function which will be able to visualize the progress of certain long running statements (i.e. LOAD DATA LOCAL INFILEarrow-up-right or ).

  • MYSQL_OPT_RECONNECT: Enable or disable automatic reconnect.

  • MYSQL_OPT_READ_TIMEOUT: Specifies the timeout in seconds for reading packets from the server.

  • MYSQL_OPT_WRITE_TIMEOUT: Specifies the timeout in seconds for sending packets to the server.

  • MYSQL_REPORT_DATA_TRUNCATION: Enable or disable reporting data truncation errors for prepared statements.

  • MYSQL_SET_CHARSET_DIR: files.

  • MYSQL_SET_CHARSET_NAME: Specify the default for the connection.

  • MYSQL_OPT_BIND: Specify the network interface from which to connect to MariaDB Server.

  • MYSQL_OPT_NONBLOCK: Specify stack size for non-blocking operations. The argument for MYSQL_OPT_NONBLOCK is the size of the stack used to save the state of a non-blocking operation while it is waiting for I/O and the application is doing other processing. Normally, applications will not have to change this, and it can be passed as zero to use the default value.

  • MYSQL_OPT_CAN_HANDLE_EXPIRED_PASSWORDS: If this option is set, the client indicates that it will be able to handle expired passwords by setting the CLIENT_CAN_HANDLE_EXPIRED_PASSWORDS capability flag. If the password has expired and CLIENT_CAN_HANDLE_EXPIRED_PASSWORDS is set, the server will not return an error when connecting, but put the connection in sandbox mode, where all commands will return error 1820 (ER_MUST_CHANGE_PASSWORD) unless a new password was set. This option was added in MariaDB Connector/C 3.0.4

  • MYSQL_OPT_MAX_ALLOWED_PACKET: The maximum packet length to send to or receive from server. The default is 16MB, the maximum 1GB.

  • MYSQL_OPT_NET_BUFFER_LENGTH: The buffer size for TCP/IP and socket communication. Default is 16KB.

  • MARIADB_OPT_SCHEMA: Database to use.

  • MARIADB_OPT_PORT: Port number to use for connection.

  • MARIADB_OPT_UNIXSOCKET: For connections to localhost, the Unix socket file to use, or, on Windows, the name of the named pipe to use.

  • MYSQL_OPT_NAMED_PIPE: For Windows operating systems only: Use named pipes for client/server communication.

  • MYSQL_OPT_PROTOCOL: Specify the type of client/server protocol. Possible values are:

    • MYSQL_PROTOCOL_TCP

    • MYSQL_PROTOCOL_SOCKET

    • MYSQL_PROTOCOL_PIPE

    • MYSQL_PROTOCOL_MEMORY.

  • MARIADB_OPT_FOUND_ROWS: Return the number of matched rows instead of number of changed rows.

  • MYSQL_OPT_COMPRESS: Use the compressed protocol for client server communication. If the server doesn't support compressed protocol, the default protocol will be used.

  • MYSQL_OPT_LOCAL_INFILE: Enable or disable the use of LOAD DATA LOCAL INFILEarrow-up-right

  • MARIADB_OPT_MULTI_STATEMENTS: Allows the client to send multiple statements in one command. Statements will be divided by a semicolon.

  • MARIADB_OPT_MULTI_RESULTS: Indicates that the client is able to handle multiple result sets from stored procedures or multi statements. This option will be automatically set if MARIADB_OPT_MULTI_STATEMENTS is set.

  • MYSQL_SHARED_MEMORY_BASE_NAME: Shared-memory name to use for Windows connections using shared memory to a local server (started with the --shared-memory option). Case-sensitive.

  • MYSQL_OPT_SSL_CA: Defines a path to a PEM file that should contain one or more X509 certificates for trusted Certificate Authorities (CAs) to use for . This option requires that you use the absolute path, not a relative path. See for more information.
  • MYSQL_OPT_SSL_CAPATH: Defines a path to a directory that contains one or more PEM files that should each contain one X509 certificate for a trusted Certificate Authority (CA) to use for . This option requires that you use the absolute path, not a relative path. The directory specified by this option needs to be run through the openssl rehasharrow-up-right command. See for more information. This option is only supported if the connector was built with OpenSSL. If the connector was built with GnuTLS or Schannel, then this option is not supported. See for more information about which libraries are used on which platforms.

  • MYSQL_OPT_SSL_CIPHER: Defines a list of permitted ciphers or cipher suites to use for .

  • MYSQL_OPT_SSL_CRL: Defines a path to a PEM file that should contain one or more revoked X509 certificates to use for . This option requires that you use the absolute path, not a relative path. See for more information. This option is only supported if the connector was built with OpenSSL or Schannel. If the connector was built with GnuTLS, then this option is not supported. See for more information about which libraries are used on which platforms.

  • MYSQL_OPT_SSL_CRLPATH: Defines a path to a directory that contains one or more PEM files that should each contain one revoked X509 certificate to use for . This option requires that you use the absolute path, not a relative path. The directory specified by this option needs to be run through the openssl rehasharrow-up-right command. See for more information. This option is only supported if the connector was built with OpenSSL. If the connector was built with GnuTLS or Schannel, then this option is not supported. See for more information about which libraries are used on which platforms.

  • MARIADB_OPT_SSL_FP: Specify the SHA1 fingerprint of a server certificate for validation during the handshake. This is deprecated. Use MARIADB_OPT_TLS_PEER_FP instead.

  • MARIADB_OPT_TLS_PEER_FP: Specify the SHA1 fingerprint of a server certificate for validation during the handshake.

  • MARIADB_OPT_SSL_FP_LIST: Specify a file which contains one or more SHA1 fingerprints of server certificates for validation during the handshake. This is deprecated. Use MARIADB_OPT_TLS_PEER_FP_LIST instead.

  • MARIADB_OPT_TLS_PEER_FP_LIST: Specify a file which contains one or more SHA1 fingerprints of server certificates for validation during the handshake.

  • MARIADB_OPT_TLS_PASSPHRASE: Specify a passphrase for a passphrase-protected private key, as configured by the MYSQL_OPT_SSL_KEY option. This option is only supported if the connector was built with OpenSSL or GnuTLS. If the connector was built with Schannel, then this option is not supported. See for more information about which libraries are used on which platforms.

  • MARIADB_OPT_TLS_VERSION: Defines which protocol versions are allowed. This should be a comma-separated list of TLS protocol versions to allow. Valid TLS protocol versions are TLSv1.0, TLSv1.1, TLSv1.2, and TLSv1.3. Both the client and server should support the allowed TLS protocol versions. See for information on which TLS libraries support which TLS protocol versions. See for more information about which TLS libraries are used on which platforms.

  • MYSQL_OPT_SSL_VERIFY_SERVER_CERT: Enables (or disables) .

  • MYSQL_OPT_SSL_ENFORCE: Whether to force . This enables TLS with the default system settings. It does not prevent the connection from being created if the server does not support TLS.

  • MARIADB_OPT_TLS_CIPHER_STRENGTH: Cipher strength. This value will be passed as an unsigned int parameter.

  • MARIADB_OPT_CONNECTION_HANDLER: Specify the name of a connection handler plugin.
  • MARIADB_OPT_USERDATA: Bundle user data to the current connection, e.g. for use in connection handler plugins. This option requires 4 parameters: connection, option, key and value.

  • MARIADB_OPT_CONNECTION_READ_ONLY: This option is used by connection handler plugins and indicates that the current connection will be used for read operations only.

  • MYSQL_PLUGIN_DIR: Specify the location of client plugins. The plugin directory can also be specified with the MARIADB_PLUGIN_DIR environment variable.

  • MYSQL_SECURE_AUTH: Refuse to connect to the server if the server uses the authentication plugin. This mode is off by default, which is a difference in behavior compared to MySQL 5.6 and later, where it is on by default.

  • MYSQL_SERVER_PUBLIC_KEY: Specifies the name of the file which contains the RSA public key of the database server. The format of this file must be in PEM format. This option is used by the client authentication plugin. It was introduced in Connector/C 3.1.0.

  • if MYSQL_READ_DEFAULT_FILE is set to a non-empty string, then it is interpreted as a path to a custom option file, and only that option file is read.
  • if MYSQL_READ_DEFAULT_GROUP is an empty string (or NULL and MYSQL_READ_DEFAULT_FILE is set) then only default groups — [client], [client-server], [client-mariadb] are read.

  • if MYSQL_READ_DEFAULT_GROUP is a non-empty string, then it is interpreted as a custom option group, and that custom option group is read in addition to default groups from above.

  • _pid: process id
  • _platform: e.g. x86 or x64

  • _server_host: the hostname (as specified in mysql_real_connect). This attribute was added in Connector/C 3.0.5

  • mysql_init()
    option files
    mysql_real_connect
    option file
    option group
    option file
    default option files
    mysql_init()
    mysql_options()
    mysql_real_connect()
    spinner
    unsigned int timeout= 5;
    mysql_optionsv(mysql, MYSQL_OPT_CONNECT_TIMEOUT, (void *)&timeout);
    int my_verify_filename(void *data, const char *filename)
    {
     return strcmp((char *)data, filename);
    }
    ...
    char *filename= "mydata.csv";
    mysql_optionsv(mysql, MARIADB_OPT_VERIFY_LOCAL_INFILE_CALLBACK, my_verify_filename, (void *)filename);
    static void report_progress(const MYSQL *mysql __attribute__((unused)),
     uint stage, uint max_stage,
     double progress __attribute__((unused)),
     const char *proc_info __attribute__((unused)),
     uint proc_info_length __attribute__((unused)))
    {
     ...
    }
    mysql_optionsv(mysql, MYSQL_PROGRESS_CALLBACK, (void *)report_progress);
    my_bool reconnect= 1; /* enable reconnect */
    mysql_optionsv(mysql, MYSQL_OPT_RECONNECT, (void *)&reconnect);
    unsigned int timeout= 5;
    mysql_optionsv(mysql, MYSQL_OPT_READ_TIMEOUT, (void *)&timeout);
    unsigned int timeout= 5;
    mysql_optionsv(mysql, MYSQL_OPT_WRITE_TIMEOUT, (void *)&timeout);
    mysql_optionsv(mysql, MYSQL_REPORT_DATA_TRUNCATION, NULL); /* disable */
    mysql_optionsv(mysql, MYSQL_REPORT_DATA_TRUNCATION, (void *)"1"); /* enable */
    mysql_optionsv(mysql, MYSQL_SET_CHARSET_DIR, (void *)"/usr/local/mysql/share/mysql/charsets");
    mysql_optionsv(mysql, MYSQL_SET_CHARSET_NAME, (void *)"utf8");
    mysql_optionsv(mysql, MYSQL_OPT_BIND, (void *)"192.168.8.3");
    mysql_optionsv(mysql, MYSQL_OPT_NONBLOCK, 0);
    mysql_optionsv(mysql, MYSQL_OPT_CAN_HANDLE_EXPIRED_PASSWORDS, 1);
    mysql_optionsv(mysql, MYSQL_OPT_MAX_ALLOWED_PACKET, 0x40000000);
    mysql_optionsv(mysql, MYSQL_OPT_NET_BUFFER_LENGTH, 0x40000000);
    mysql_optionsv(mysql, MARIADB_OPT_SCHEMA, (void *)"mydb");
    mysql_optionsv(mysql, MARIADB_OPT_PORT, 3307);
    mysql_optionsv(mysql, MARIADB_OPT_UNIXSOCKET, (void *)"/var/lib/mysql/mysql.sock");
    mysql_optionsv(mysql, MYSQL_OPT_NAMED_PIPE, NULL);
    mysql_optionsv(mysql, MARIADB_OPT_FOUND_ROWS, 1);
    mysql_optionsv(mysql, MYSQL_OPT_COMPRESS, NULL);
    unsigned int enable= 1, disable= 0;
    mysql_optionsv(mysql, MYSQL_OPT_LOCAL_INFILE, (void *)&disable);/* disable */
    mysql_optionsv(mysql, MYSQL_OPT_LOCAL_INFILE, (void *)NULL);     /* enable */
    mysql_optionsv(mysql, MYSQL_OPT_LOCAL_INFILE, (void *)&enable); /* enable */
    mysql_optionsv(mysql, MARIADB_OPT_MULTI_STATEMENTS, (void *)"");
    mysql_optionsv(mysql, MARIADB_OPT_MULTI_RESULTS, 1);
    mysql_optionsv(mysql, MYSQL_SHARED_MEMORY_BASE_NAME, (void *)"mariadb");
    mysql_optionsv(mysql, MYSQL_OPT_SSL_CAPATH, (void *)"certs/ca-cert.pem");
    mysql_optionsv(mysql, MYSQL_OPT_SSL_CIPHER, (void *)"DHE-RSA-AES256-SHA");
    mysql_optionsv(mysql, MYSQL_OPT_SSL_CAPATH, (void *)"certs/ca-cert.pem");\\\\<<code>>mysql_optionsv(mysql, MYSQL_OPT_SSL_CRL, (void *)"certs/crl.pem");
    mysql_optionsv(mysql, MYSQL_OPT_SSL_CAPATH, (void *)"certs/ca-cert.pem");\\\\<<code>>mysql_optionsv(mysql, MYSQL_OPT_SSL_CRLPATH, (void *)"certs/crls");
    mysql_optionsv(mysql, MARIADB_OPT_SSL_FP, (void *)"3a079e1a14ad326953a5d280f996b93d772a5bea");
    mysql_optionsv(mysql, MARIADB_OPT_TLS_PEER_FP, (void *)"3a079e1a14ad326953a5d280f996b93d772a5bea");
    mysql_optionsv(mysql, MARIADB_OPT_SSL_FP_LIST, (void *)"certs/fingerprints.txt");
    mysql_optionsv(mysql, MARIADB_OPT_TLS_PEER_FP_LIST, (void *)"certs/fingerprints.txt");
    mysql_optionsv(mysql, MARIADB_OPT_SSL_PASSPHRASE, (void *)"thisisashortpassphrase");
    mysql_optionsv(mysql, MARIADB_OPT_TLS_VERSION, (void *)"TLSv1.2,TLSv1.3");
    my_bool verify= 1;
    mysql_optionsv(mysql, MYSQL_OPT_SSL_VERIFY_SERVER_CERT, (void *)&verify);
    my_bool enforce_tls= 1;
    mysql_optionsv(mysql, MYSQL_OPT_SSL_ENFORCE, (void *)&enforce_tls);
    unsigned int cipher_strength= 128;
    mysql_optionsv(mysql, MARIADB_OPT_TLS_CIPHER_STRENGTH, (void*)&cipher_strength);
    mysql_optionsv(mysql, MARIADB_OPT_USERDATA, (void *)"ssh_user", (void *)ssh_user);
    my_bool read_only= 1;
    mysql_optionsv(mysql, MARIADB_OPT_CONNECTION_READ_ONLY, (void *)&read_only);
    mysql_optionsv(mysql, MYSQL_PLUGIN_DIR, (void *)"/opt/mariadb/lib/plugins");
    mysql_optionsv(mysql, MYSQL_SECURE_AUTH, 1);
    mysql_optionsv(mysql, MYSQL_SERVER_PUBLIC_KEY, (void *)(void *)"certs/server-cert.pem);
    mysql_optionsv(mysql, MYSQL_INIT_COMMAND, (void *)"CREATE TABLE test.t1(a int)");
    mysql_optionsv(mysql, MYSQL_INIT_COMMAND, (void *)"SET @value := 1");
    mysql_optionsv(mysql, MARIADB_OPT_HOST, (void *)"dbserver.example.com");
    mysql_optionsv(mysql, MARIADB_OPT_USER, (void *)"myuser");
    mysql_optionsv(mysql, MARIADB_OPT_PASSWORD, (void *)"horsebattery");
    mysql_optionsv(mysql, MYSQL_OPT_SSL_KEY, (void *)"certs/client-key.pem");
    mysql_optionsv(mysql, MYSQL_OPT_SSL_CERT, (void *)"certs/client-cert.pem");
    mysql_optionsv(mysql, MYSQL_DEFAULT_AUTH, (void *)"ed25519");
    mysql_optionsv(mysql, MYSQL_ENABLE_CLEARTEXT_PLUGIN, 1);
    mysql_optionsv(mysql, MYSQL_OPT_CONNECT_ATTR_DELETE, (void *)"app_version");
    mysql_optionsv(mysql, MYSQL_OPT_CONNECT_ATTR_ADD, (void *)"app_version", (void *)"2.0.1");
    mysql_optionsv(mysql, MYSQL_OPT_CONNECT_ATTR_RESET, 0);
    mysql_optionsv(mysql, MYSQL_OPT_SSL_CA, (void *)"certs/ca-cert.pem");
    mysql_optionsv(mysql, MARIADB_OPT_CONNECTION_HANDLER, (void *)"aurora");
    enum mysql_protocol_type prot_type= MYSQL_PROTOCOL_SOCKET;
    mysql_optionsv(mysql, MYSQL_OPT_PROTOCOL, (void *)&prot_type);

    Configuring MariaDB Connector/C with Option Files

    Just like MariaDB Server and libmysqlclient, MariaDB Connector/C can also read configuration options from client in .

    hashtag
    Default Option File Locations

    MariaDB Connector/C reads option files from many different directories by default. See the sections below to find out which directories are checked for which system.

    MariaDB Connector/C allows application developers to read options from the default option files by calling the mysql_optionsv function and providing the MYSQL_READ_DEFAULT_FILE option name and a NULL pointer as arguments. For example:

    hashtag
    Default Option File Locations on Linux, Unix, Mac

    On Linux, Unix, or Mac OS X, the default option file is called my.cnf. MariaDB Connector/C looks for the MariaDB option file in the locations and orders listed below.

    The locations are dependent on whether the DEFAULT_SYSCONFDIR option was defined when MariaDB Connector/C was built. This option is usually defined as /etc when building , but it is usually not defined when building or .

    • When the DEFAULT_SYSCONFDIR option was not defined, MariaDB Connector/C looks for the MariaDB option file in the following locations in the following order:

    Location
    • When the DEFAULT_SYSCONFDIR option was defined, MariaDB Connector/C looks for the MariaDB option file in the following locations in the following order:

    Location

    hashtag
    Default Option File Locations on Windows

    On Windows, the default option file can be called either my.ini or my.cnf. MariaDB Connector/C looks for the MariaDB option file in the following locations in the following order:

    Location
    • The System Windows Directory is the directory returned by the function. The value is usually C:\Windows. To find its specific value on your system, open and execute:

    • The Windows Directory is the directory returned by the function. The value may be a private Windows Directory for the application, or it may be the same as the System Windows Directory returned by the function.

    • EXEDIR is the parent directory of the executable program that MariaDB Connector/C is linked with.

    hashtag
    Default Option File Hierarchy

    MariaDB Connector/C will look in all of the above locations, in order, even if has already found an option file, and it's possible for more than one option file to exist. For example, you could have an option file in /etc/my.cnf with global settings for all servers, and then you could another option file in ~/.my.cnf (i.e.your user account's home directory) which will specify additional settings (or override previously specified setting) that are specific only to that user.

    hashtag
    Custom Option File Locations

    MariaDB Connector/C allows application developers to read option files from a custom option file by calling the function and providing the option name and an option file path as arguments. For example:

    Many MariaDB clients can be configured to read options from custom options files with the following command-line arguments. They must be given as the first argument on the command-line. Application developers who use MariaDB Connector/C in their application and rely on option files may also want to consider implementing these command-line arguments:

    Option
    Description

    The command-line option is roughly equivalent to setting the option with a non-NULL argument.

    The command-line option does not yet have an equivalent option in MariaDB Connector/C. See for more information.

    hashtag
    Option File Syntax

    The syntax of the MariaDB option files are:

    • Lines starting with

    hashtag
    are comments.

    • Empty lines are ignored.

    • Option groups use the syntax [group-name]. See the section below for more information on available option groups.

    • The same option group can appear multiple times.

    hashtag
    Option Groups

    MariaDB Connector/C reads client options from the following in :

    Group
    Description

    MariaDB Connector/C allows application developers to read options from these option groups by calling the function and providing the option name and a NULL pointer as arguments.

    For example:

    hashtag
    Custom Option Groups

    MariaDB Connector/C allows application developers to read options from a custom option group by calling the function and providing the option name and the name of the custom option group as arguments.

    For example:

    The custom option group will be read in addition to the default option groups listed above.

    Many MariaDB clients can be configured to read options from option groups with a custom suffix by providing the following command-line argument. It must be given as the first argument on the command-line. Application developers who use MariaDB Connector/C in their application and rely on option files may also want to consider implementing this command-line argument:

    Option
    Description

    The command-line option does not yet have an equivalent option in MariaDB Connector/C. See for more information.

    hashtag
    Including Option Files

    It is possible to include additional option files from another option file. For example, to include /etc/mysql/dbserver1.cnf, an option file could contain:

    hashtag
    Including Option File Directories

    It is also possible to include the default option files in a directory from another option file. For example, to include the default option files in /etc/my.cnf.d/, an option file could contain:

    Unlike with MariaDB server, this directive does not configure MariaDB Connector/C to include all option files ending in .cnf on Unix-like operating systems or all option files ending in .cnf and .ini files on Windows. Instead, it just configures MariaDB Connector/C to include the my.cnf in the given directory, and also the my.ini in the given directory if it's Windows. See for more information.

    hashtag
    Checking Program Options

    For many MariaDB clients, you can check which options a given program is going to use by using the command-line argument:

    Option
    Description

    It must be given as the first argument on the command-line. Application developers who use MariaDB Connector/C in their application and rely on option files may also want to consider implementing this command-line argument. For example:

    If it is installed on your system, then you can also check which options a given program is going to use by using the utility and providing the names of the option groups that the program reads.

    For example:

    See for more information.

    hashtag
    MySQL 5.6 Obfuscated Authentication Credential Option File

    MySQL 5.6 and above support an obfuscated authentication credential option file called .mylogin.cnf that is created with .

    MariaDB Connector/C does not support this. The passwords in MySQL's .mylogin.cnf are only obfuscated, rather than encrypted, so the feature does not really add much from a security perspective. It is more likely to give users a false sense of security, rather than to seriously protect them.

    hashtag
    Options

    MariaDB Connector/C options can be set in client .

    Unlike with the server, dashes (-) and underscores (_) in options are not interchangeable for MariaDB Connector/C. Options must be specified exactly as they are defined. See for more information.

    Unlike with the server, the loose prefix has no meaning for MariaDB Connector/C. Unknown options will simply be ignored.

    hashtag
    Custom Options

    MariaDB Connector/C allows application developers to implement custom options in option files by defining a function that matches this signature:

    And then assigning the function pointer to mysql->options.extension->set_option.

    hashtag
    Default Options

    These are the options supported in option files by MariaDB Connector/C by default.

    These options can also be set inside your application with the function.

    bind-address

    • Description: Specify the network interface from which to connect to MariaDB Server.

    • mysql_optionsv: MYSQL_OPT_BIND

    • Data Type: string

    character-sets-dir

    • Description: Directory for files.

    • mysql_optionsv: MYSQL_SET_CHARSET_DIR

    • Data Type: string

    compress

    • Description: Compress all information sent between the client and the server if both support compression.

    • mysql_optionsv: MYSQL_OPT_COMPRESS

    • Data Type: boolean

    connect-timeout, timeout

    • Description: Connect timeout in seconds. This value will be passed as an unsigned int parameter.

    • mysql_optionsv: MYSQL_OPT_CONNECT_TIMEOUT

    • Data Type: int

    database

    • Description: Database to use.

    • mysql_optionsv: MARIADB_OPT_SCHEMA

    • Data Type: string

    debug

    • Description:

    • mysql_optionsv: MARIADB_OPT_DEBUG

    • Data Type: string

    default-auth

    • Description: Default authentication client-side plugin to use.

    • mysql_optionsv: MYSQL_DEFAULT_AUTH

    • Data Type: string

    default-character-set

    • Description: Specify the default for the connection.

    • mysql_optionsv: MYSQL_SET_CHARSET_NAME

    • Data Type: string

    disable-local-infile

    • Description: Disable the use of .

    • mysql_optionsv: N/A

    • Data Type: string

    host

    • Description: Hostname or IP address of the server to connect to.

    • mysql_optionsv: MARIADB_OPT_HOST

    • Data Type: string

    interactive-timeout

    • Description:

    • mysql_optionsv: MARIADB_OPT_INTERACTIVE

    • Data Type: none

    init-command

    • Description: Command(s) which will be executed when connecting and reconnecting to the server.

    • mysql_optionsv: MYSQL_INIT_COMMAND

    • Data Type: string

    local-infile

    • Description: Enable or disable the use of .

    • mysql_optionsv: MYSQL_OPT_LOCAL_INFILE

    • Data Type: boolean

    max-allowed-packet

    • Description: The maximum packet length to send to or receive from server. The default is 16MB, the maximum 1GB.

    • mysql_optionsv: MYSQL_OPT_MAX_ALLOWED_PACKET

    • Data Type: size_t

    multi-results

    • Description: Indicates that the client is able to handle multiple result sets from stored procedures or multi statements. This option will be automatically set if multi-statements is set.

    • mysql_optionsv: MARIADB_OPT_MULTI_RESULTS

    • Data Type: none

    multi-statements, multi-queries

    • Description: Allows the client to send multiple statements in one command. Statements will be divided by a semicolon.

    • mysql_optionsv: MARIADB_OPT_MULTI_STATEMENTS

    • Data Type: string

    net-buffer-length

    • Description: The buffer size for TCP/IP and socket communication. Default is 16KB.

    • mysql_optionsv: MYSQL_OPT_NET_BUFFER_LENGTH

    • Data Type: size_t

    password

    • Description: Password of the user to login to the server.

    • mysql_optionsv: MARIADB_OPT_PASSWORD

    • Data Type: string

    pipe

    • Description: For Windows operating systems only: Use named pipes for client/server communication.

    • mysql_optionsv: MYSQL_OPT_NAMED_PIPE

    • Data Type: boolean

    plugin-dir

    • Description: Specify the location of client plugins.

      • The plugin directory can also be specified with the MARIADB_PLUGIN_DIR environment variable.

    • mysql_optionsv: MYSQL_PLUGIN_DIR

    port

    • Description: Port number to use for connection.

    • mysql_optionsv: MARIADB_OPT_PORT

    • Data Type: int

    protocol

    • Description: Specify the type of client/server protocol. Possible values are:

      • 0 - Refers to MYSQL_PROTOCOL_DEFAULT

      • 1 - Refers to

    reconnect

    • Description: Enable or disable automatic reconnect.

    • mysql_optionsv: MYSQL_OPT_RECONNECT

    • Data Type: boolean

    report-data-truncation

    • Description: Enable or disable reporting data truncation errors for prepared statements.

    • mysql_optionsv: MYSQL_REPORT_DATA_TRUNCATION

    • Data Type: boolean

    return-found-rows

    • Description: Return the number of matched rows instead of number of changed rows.

    • mysql_optionsv: MARIADB_OPT_FOUND_ROWS

    • Data Type: none

    secure-auth

    • Description: Refuse client connecting to server if it uses old (pre-MySQL4.1.1) protocol. Defaults to false (unlike MySQL since 5,6, which defaults to true).

    • mysql_optionsv: MYSQL_SECURE_AUTH

    • Data Type: boolean

    server_public_key

    • Description: Specifies the name of the file which contains the RSA public key of the database server. The format of this file must be in PEM format. This option is used by the client authentication plugin.

    • mysql_optionsv: MYSQL_SERVER_PUBLIC_KEY

    • Data Type: string

    shared-memory-base-name

    • Description: Shared-memory name to use for Windows connections using shared memory to a local server (started with the --shared-memory option). Case-sensitive.

    • mysql_optionsv: MYSQL_SHARED_MEMORY_BASE_NAME

    • Data Type: string

    socket

    • Description: For connections to localhost, the Unix socket file to use, or, on Windows, the name of the named pipe to use.

    • mysql_optionsv: MARIADB_OPT_UNIXSOCKET

    • Data Type: string

    ssl-ca

    • Description: Defines a path to a PEM file that should contain one or more X509 certificates for trusted Certificate Authorities (CAs) to use for . This option requires that you use the absolute path, not a relative path.

      • See for more information.

    • mysql_optionsv: MYSQL_OPT_SSL_CA

    ssl-capath

    • Description: Defines a path to a directory that contains one or more PEM files that should each contain one X509 certificate for a trusted Certificate Authority (CA) to use for . This option requires that you use the absolute path, not a relative path. The directory specified by this option needs to be run through the command.

      • See for more information.

      • This option is only supported if the connector was built with OpenSSL. If the connector was built with GnuTLS or Schannel, then this option is not supported. See for more information about which libraries are used on which platforms.

    ssl-cert

    • Description: Defines a path to the X509 certificate file to use for . This option requires that you use the absolute path, not a relative path.

    • mysql_optionsv: MYSQL_OPT_SSL_CERT

    • Data Type: string

    ssl-cipher

    • Description: List of permitted ciphers or cipher suites to use for .

    • mysql_optionsv: MYSQL_OPT_SSL_CIPHER

    • Data Type: string

    ssl-crl

    • Description: Defines a path to a PEM file that should contain one or more revoked X509 certificates to use for . This option requires that you use the absolute path, not a relative path.

      • See for more information.

      • This option is only supported if the connector was built with OpenSSL or Schannel. If the connector was built with GnuTLS, then this option is not supported. See for more information about which libraries are used on which platforms.

    ssl-crlpath

    • Description: Defines a path to a directory that contains one or more PEM files that should each contain one revoked X509 certificate to use for . This option requires that you use the absolute path, not a relative path. The directory specified by this option needs to be run through the command.

      • See for more information.

      • This option is only supported if the connector was built with OpenSSL. If the connector was built with GnuTLS or Schannel, then this option is not supported. See for more information about which libraries are used on which platforms.

    ssl-enforce

    • Description: Whether to force .

    • mysql_optionsv: MYSQL_OPT_SSL_ENFORCE

    • Data Type: boolean

    ssl-fp

    • Description: Specify the SHA1 fingerprint of a server certificate for validation during the handshake.

    • mysql_optionsv: MARIADB_OPT_SSL_FP

    • Data Type: string

    ssl-fp-list, ssl-fplist

    • Description: Specify a file which contains one or more SHA1 fingerprints of server certificates for validation during the handshake.

    • mysql_optionsv: MARIADB_OPT_SSL_FP_LIST

    • Data Type: string

    ssl-key

    • Description: Defines a path to a private key file to use for . This option requires that you use the absolute path, not a relative path. If the key is protected with a passphrase, the passphrase needs to be specified with ssl-passphrase option.

    • mysql_optionsv: MYSQL_OPT_SSL_KEY

    • Data Type: string

    ssl-passphrase

    • Description: Specify a passphrase for a passphrase-protected private key, as configured by the option.

      • This option is only supported if the connector was built with OpenSSL or GnuTLS. If the connector was built with Schannel, then this option is not supported. See for more information about which libraries are used on which platforms.

    • mysql_optionsv: MARIADB_OPT_TLS_PASSPHRASE

    ssl-verify-server-cert

    • Description: Enables (or disables) .

    • mysql_optionsv: MYSQL_OPT_SSL_VERIFY_SERVER_CERT

    • Data Type: boolean

    tls_version

    • Description: Defines which protocol versions are allowed. This should be a comma-separated list of TLS protocol versions to allow. Valid TLS protocol versions are TLSv1.0, TLSv1.1, TLSv1.2, and TLSv1.3. Both the client and server should support the allowed TLS protocol versions. See for information on which TLS libraries support which TLS protocol versions. See for more information about which TLS libraries are used on which platforms.

    • mysql_optionsv: MARIADB_OPT_TLS_VERSION

    user

    • Description: User to login to the server.

    • mysql_optionsv: MARIADB_OPT_USER

    • Data Type: string

    hashtag
    See Also

    MYSQL_HOME is the containing the path to the directory holding the server-specific my.cnf file.

    The !include directive can be used to include other option files. See the section below for more information on this syntax.
  • Unlike with the server, the !includedir directive does not include all .cnf files (and potentially .ini files) in a given directory. Instead, it reads the my.cnf and (potentially the my.ini) in the given directory. See for more information. See the section below for more information on this syntax.

  • Dashes (-) and underscores (_) in options are interchangeable in MariaDB Connector C 3.1.1 and later. In versions before that, options must be specified exactly as they are defined. See for more information.

  • MariaDB Connector/C does not support the that are supported by MariaDB Server. See for more information.

  • See the section below for information about available options.

  • Default Value:

  • Introduced: MariaDB Connector/C 3.0.0

  • Default Value:

    Default Value: false

    Default Value:

    Default Value:

    Default Value:

    Default Value:

    Default Value:

    Default Value:

    Default Value:

    Default Value:

    Default Value:

    Default Value: false

    Default Value:

    Default Value:

    Default Value:

    Default Value:

  • Introduced: MariaDB Connector/C 3.0.0

  • Default Value:

    Default Value: false

    Data Type: string

  • Default Value:

  • Default Value: 3306

    MYSQL_PROTOCOL_TCP
  • 2 - Refers to MYSQL_PROTOCOL_SOCKET

  • 3 - Refers to MYSQL_PROTOCOL_PIPE

  • 4 - Refers to MYSQL_PROTOCOL_MEMORY

  • mysql_optionsv: MYSQL_OPT_PROTOCOL

  • Data Type: int

  • Default Value:

  • Default Value: false

  • Introduced: MariaDB Connector/C 3.0.0

  • Default Value:

    Default Value:

    Default Value: false

    Default Value:

  • Introduced: MariaDB Connector/C 3.1.0

  • Default Value:

    Default Value:

    Data Type: string

  • Default Value:

  • mysql_optionsv: MYSQL_OPT_SSL_CAPATH

  • Data Type: string

  • Default Value:

  • Default Value:

    Default Value:

    mysql_optionsv: MYSQL_OPT_SSL_CRL

  • Data Type: string

  • Default Value:

  • Introduced: MariaDB Connector/C 3.1.1

  • mysql_optionsv: MYSQL_OPT_SSL_CRLPATH

  • Data Type: string

  • Default Value:

  • Introduced: MariaDB Connector/C 3.1.1

  • Default Value:

  • Introduced: MariaDB Connector/C 3.1.1

  • Default Value:

  • Introduced: MariaDB Connector/C 3.0.0

  • Default Value:

  • Introduced: MariaDB Connector/C 3.0.0

  • Default Value:

  • Data Type: string

  • Default Value:

  • Introduced: MariaDB Connector/C 3.0.0

  • Default Value:

  • Introduced: MariaDB Connector/C 3.0.0

  • Data Type: string

  • Default Value:

  • Introduced: MariaDB Connector/C 3.0.4

  • Default Value:

    /etc/my.cnf

    /etc/mysql/my.cnf

    $MYSQL_HOME/my.cnf

    ~/.my.cnf

    DEFAULT_SYSCONFDIR/my.cnf

    $MYSQL_HOME/my.cnf

    ~/.my.cnf

    System Windows Directory\my.ini

    System Windows Directory\my.cnf

    Windows Directory\my.ini

    Windows Directory\my.cnf

    C:\my.ini

    C:\my.cnf

    EXEDIR\my.ini

    EXEDIR\my.cnf

    %MYSQL_HOME%\my.ini

    %MYSQL_HOME%\my.cnf

    =path

    Only read options from the given option file.

    =path

    Read this extra option file after all other option files are read.

    [client]

    Options read by all MariaDB and MySQL client programs, which includes both MariaDB and MySQL clients. For example, mysqldump.

    [client-server]

    Options read by all MariaDB client programs and the MariaDB Server. This is useful for options like socket and port, which is common between the server and the clients.

    [client-mariadb]

    Options read by all MariaDB client programs.

    =suffix

    In addition to the default option groups, also read option groups with the given suffix.

    Read options from option files, print all option values, and then exit the program.

    cmakearrow-up-right
    GetSystemWindowsDirectoryarrow-up-right
    cmd.exearrow-up-right
    GetWindowsDirectoryarrow-up-right
    GetSystemWindowsDirectoryarrow-up-right
    mysql_optionsv
    MYSQL_READ_DEFAULT_FILE
    --arrow-up-right
    MYSQL_READ_DEFAULT_FILE
    --arrow-up-right
    CONC-399arrow-up-right
    Option Groups
    mysql_optionsv
    MYSQL_READ_DEFAULT_GROUP
    mysql_optionsv
    MYSQL_READ_DEFAULT_GROUP
    --arrow-up-right
    CONC-404arrow-up-right
    CONC-396arrow-up-right
    --arrow-up-right
    mysql_config_editorarrow-up-right
    option groups
    CONC-395arrow-up-right
    mysql_optionsv
    openssl rehasharrow-up-right
    openssl rehasharrow-up-right
    ssl-key
    spinner
    mysql_optionsv(mysql, MYSQL_READ_DEFAULT_FILE, NULL);
    echo %WINDIR%
    mysql_optionsv(mysql, MYSQL_READ_DEFAULT_FILE, (void *)"./my_conf.cnf");
    mysql_optionsv(mysql, MYSQL_READ_DEFAULT_GROUP, NULL);
    mysql_optionsv(mysql, MYSQL_READ_DEFAULT_GROUP, (void *)"my_section");
    [client-mariadb]
    ...
    !include /etc/mysql/dbserver1.cnf
    [client-mariadb]
    ...
    !includedir /etc/my.cnf.d/
    mysqldump --print-defaults
    mysqldump would have been started with the following arguments:
    --ssl_cert=/etc/my.cnf.d/certificates/client-cert.pem --ssl_key=/etc/my.cnf.d/certificates/client-key.pem --ssl_ca=/etc/my.cnf.d/certificates/ca.pem --ssl-verify-server-cert --max_allowed_packet=1GB
    my_print_defaults my_section client client-server client-mariadb
    --ssl_cert=/etc/my.cnf.d/certificates/client-cert.pem
    --ssl_key=/etc/my.cnf.d/certificates/client-key.pem
    --ssl_ca=/etc/my.cnf.d/certificates/ca.pem
    --ssl-verify-server-cert
    --max_allowed_packet=1GB
    my_bool (*set_option)(MYSQL *mysql, const char *config_option, const char *config_value);
    Including Option Files
    CONC-396arrow-up-right
    Including Option File Directories
    CONC-395arrow-up-right
    CONC-415arrow-up-right
    Options
    Licensing FAQ
    Licensing FAQ
    character set
    autocommit
    INSERT
    UPDATE
    DELETE
    REPLACE
    UPDATE
    REPLACE
    error log
    error code
    character set
    AUTO_INCREMENT
    LAST_INSERT_ID(expr)
    INSERT
    UPDATE
    AUTO_INCREMENT
    LAST_INSERT_ID
    AUTO INCREMENT
    LAST_INSERT_ID()
    TLS connection
    autocommit
    SHOW STATUS
    autocommit
    Autocommit
    SHOW PROCESSLIST
    SELECT DATABASE()
    secure TLS connection
    INSERT
    UPDATE
    SELECT ...
    INSERT INTO...SELECT...
    INSERT INTO...VALUES (...),(...),(...)
    LOAD DATA INFILE ...
    ALTER TABLE ...
    UPDATE ...
    MariaDB Package Repository setup script
    MariaDB Repository Configuration Tool
    protocol capabilities
    protocol capabilities
    --debug
    character set
    mariadb_es_repo_setup
    mariadb_repo_setup
    Versions
    MariaDB Package Repository Setup and Usage
    mariadb_es_repo_setup
    Versions
    MariaDB Package Repository Setup and Usage
    mariadb_repo_setup
    --mariadb-server-version
    --mariadb-server-version
    mariadb_es_repo_setup
    mariadb_repo_setup
    TLS
    TLS
    mysql_clear_password
    session_connect_attrs
    session_account_connect_attrs
    Performance Schema
    ALTER TABLE
    character set
    character set
    TLS
    Secure Connections Overview: Certificate Authorities (CAs)
    TLS
    Secure Connections Overview: Certificate Authorities (CAs)
    TLS and Cryptography Libraries Used by MariaDB
    TLS
    TLS
    Secure Connections Overview: Certificate Revocation Lists (CRLs)
    TLS and Cryptography Libraries Used by MariaDB
    TLS
    Secure Connections Overview: Certificate Revocation Lists (CRLs)
    TLS and Cryptography Libraries Used by MariaDB
    TLS
    TLS
    TLS
    TLS
    TLS and Cryptography Libraries Used by MariaDB
    TLS
    Secure Connections Overview: TLS Protocol Version Support
    TLS and Cryptography Libraries Used by MariaDB
    server certificate verification
    TLS
    mysql_old_password
    caching_sha2_password
    option groups
    option files
    RPM packages
    DEB packages
    binary tarballs
    cmake
    cmake
    defaults-file
    defaults-extra-file
    option groups
    option files
    defaults-group-suffix
    print-defaults
    my_print_defaults
    Configuring MariaDB with Option Files: Checking Program Options
    character set
    character set
    LOAD DATA LOCAL INFILE
    LOAD DATA LOCAL INFILE
    caching_sha2_password
    TLS
    Secure Connections Overview: Certificate Authorities (CAs)
    TLS
    Secure Connections Overview: Certificate Authorities (CAs)
    TLS and Cryptography Libraries Used by MariaDB
    TLS
    TLS
    TLS
    Secure Connections Overview: Certificate Revocation Lists (CRLs)
    TLS and Cryptography Libraries Used by MariaDB
    TLS
    Secure Connections Overview: Certificate Revocation Lists (CRLs)
    TLS and Cryptography Libraries Used by MariaDB
    TLS
    TLS
    TLS
    TLS
    TLS and Cryptography Libraries Used by MariaDB
    server certificate verification
    TLS
    Secure Connections Overview: TLS Protocol Version Support
    TLS and Cryptography Libraries Used by MariaDB
    Configuring MariaDB with Option Files
    environment variable
    option prefixes
    --defaults-file
    --defaults-extra-file
    --defaults-group-suffix
    --print-defaults
    MSI packages
    binary tarballs
    MariaDB Package Repository setup script
    RPM package
    yum
    dnf
    DEB package
    RPM package
    zypper
    option groups
    option files
    Connector/C 3.4.8
    MariaDB 10.2