LLMpediaThe first transparent, open encyclopedia generated by LLMs

libmysqlclient

Generated by GPT-5-mini
Note: This article was automatically generated by a large language model (LLM) from purely parametric knowledge (no retrieval). It may contain inaccuracies or hallucinations. This encyclopedia is part of a research project currently under review.
Article Genealogy
Parent: ProxySQL Hop 4
Expansion Funnel Raw 63 → Dedup 0 → NER 0 → Enqueued 0
1. Extracted63
2. After dedup0 (None)
3. After NER0 ()
4. Enqueued0 ()
libmysqlclient
Namelibmysqlclient
AuthorMySQL AB
DeveloperOracle Corporation
Released1995
Latest release version8.0.x (varies)
Operating systemLinux, Microsoft Windows, macOS, FreeBSD
GenreDatabase client library
LicenseDual-licensed (GPL and proprietary)

libmysqlclient

libmysqlclient is the canonical C client library for the MySQL relational database engine, providing an API used by numerous database connectors, language bindings, and applications. It implements client–server communication, authentication, and query protocols used by MySQL AB and later maintained by Oracle Corporation after acquisition. The library has been a foundational component in stacks that include LAMP, XAMPP, and many cloud and on-premises deployments involving Amazon Web Services, Google Cloud Platform, and Microsoft Azure services.

Overview

libmysqlclient exposes a C API enabling applications to connect to MySQL servers, execute SQL statements, retrieve results, and manage connections, transactions, and prepared statements. It is widely used by drivers and wrappers for languages and projects such as PHP, Python (via adapters), Perl, Ruby, Node.js (native addons), Java (native connectors in some cases), Go (CGO-based drivers), Drupal, WordPress, and Joomla!. The library implements protocol features introduced across major MySQL releases and is distributed as part of server packages, client distributions, and standalone development packages used during compilation of client applications and language bindings.

History and Development

Development of libmysqlclient began alongside the initial MySQL server in the 1990s under MySQL AB. During that period the library evolved to support features introduced in MySQL 3.23, MySQL 4.0, MySQL 5.0 (stored procedures), and later innovations such as the MySQL 5.6 performance schema and MySQL 8.0 authentication and protocol changes. After the acquisition of MySQL AB by Sun Microsystems and subsequently by Oracle Corporation, maintenance and releases of libmysqlclient continued under Oracle's stewardship, while alternative implementations and forks emerged from projects like MariaDB and Percona Server. The presence of libmysqlclient as a reference client influenced interoperability efforts with standards bodies and projects such as ODBC, JDBC, and database abstraction layers used in Django, Symfony, and Ruby on Rails.

Architecture and API

The library follows a procedural C API model exposing functions for connection management, query submission, result retrieval, error handling, and prepared statement lifecycle. Core concepts in the API include MYSQL connection handles, MYSQL_RES result sets, MYSQL_STMT prepared-statement objects, and MYSQL_FIELD metadata descriptors. The protocol implementation handles authentication plugins including native password methods and newer plugins introduced alongside MySQL 8.0 such as caching_sha2_password. Transaction control interfaces align with SQL standards adopted by InnoDB, and client options interoperate with server-side configuration options used in my.cnf/my.ini. The architecture permits use in multithreaded applications and integrates with eventing and networking stacks on systems such as Linux with epoll and FreeBSD with kqueue.

Compatibility and Platforms

libmysqlclient is distributed for mainstream platforms including Linux, Microsoft Windows, macOS, FreeBSD, and various BSD derivatives. Binary compatibility is maintained across minor versions for client programs compiled against specific sonames, while protocol compatibility between client and server versions is preserved for a wide range of combinations, though certain features require matching server versions (for example, JSON functions and new authentication plugins introduced in MySQL 5.7 and MySQL 8.0). Distributions such as Debian, Ubuntu, Red Hat Enterprise Linux, CentOS, and Fedora package libmysqlclient as development and runtime artifacts used by system packages and third-party applications.

Usage and Examples

Typical usage in C begins with initializing a MYSQL handle, calling mysql_real_connect to establish a connection to a MySQL server, issuing mysql_query or using prepared statements via mysql_stmt_prepare/mysql_stmt_execute, and iterating over results with mysql_store_result/mysql_fetch_row or mysql_stmt_fetch. Language bindings and connectors wrap these primitives for use in projects like PHP's mysqli extension, Python DB-API modules, and Perl DBI DBD drivers. Applications such as phpMyAdmin, Adminer, and custom middleware leverage libmysqlclient either directly or via wrappers to perform schema migrations, replication setup with Group Replication, and data export/import operations used in ETL workflows and backup tools compatible with mysqldump and Percona XtraBackup.

Performance and Limitations

Performance characteristics depend on network latency, client-side buffering (store vs. use result), prepared statement reuse, and protocol optimizations present in given libmysqlclient releases. Benchmarks comparing client libraries often include comparisons with forks like the MariaDB Connector/C and projects such as Connector/C++ and language-native implementations; these comparisons involve throughput, latency, memory usage, and CPU efficiency under workloads modeled after TPC-C and sysbench benchmarks. Limitations include tight coupling to the MySQL protocol, necessary updates to support new authentication plugins, and ABI breakages across major releases that can complicate binary distribution. Alternative clients or proxies (for example, ProxySQL or MaxScale) are sometimes used to address scaling and routing limitations.

Licensing and Distribution

libmysqlclient historically used a dual-licensing model, distributed under the GNU General Public License (GPL) for open-source use and available under proprietary commercial licenses for embedding in closed-source products. Oracle continues to provide client libraries with licensing and distribution choices, while forks and compatible implementations from MariaDB Corporation Ab and Percona offer different licensing terms and ABI compatibility decisions. Packaged distributions from Debian, Ubuntu, Red Hat, and others provide libmysqlclient in their repositories under terms that align with their packaging policies and the upstream licensing model.

Category:Client libraries Category:MySQL