# mysql/mysql-server architecture

> Architecture diagram of the GitHub repository mysql/mysql-server, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mysql/mysql-server
- Repository: https://github.com/mysql/mysql-server

## Overview

MySQL is a relational SQL database server, accompanied here by command-line clients, server components, and MySQL Router’s REST-service metadata layer. The principal workflow is a client submitting SQL to the server and receiving results. The tree and README establish the product and subsystem scope; sampled excerpts support details for client query attributes, transaction inspection, keyring metadata, resource-manager queries, and REST metadata loading, but do not expose the general SQL execution or storage implementation.

Main entry points: [`sql/server_component`](https://github.com/mysql/mysql-server/tree/trunk/sql/server_component) (SQL database server), [`client/mysql.cc`](https://github.com/mysql/mysql-server/blob/trunk/client/mysql.cc) (SQL client), [`components/keyrings/keyring_file/keyring_file.cc`](https://github.com/mysql/mysql-server/blob/trunk/components/keyrings/keyring_file/keyring_file.cc) (File keyring), [`client/mysqldump.cc`](https://github.com/mysql/mysql-server/blob/trunk/client/mysqldump.cc) (Dump and export)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_clients["Client tools"]
  node_mysql_cli["SQL client<br/>[mysql.cc]"]
  node_dump["Dump and export<br/>[mysqldump.cc]"]
  node_import["Data import<br/>[mysqlimport.cc]"]
  node_admin["Administration tools<br/>[mysqladmin.cc]"]
  node_binlog["Binlog tools<br/>[mysqlbinlog.cc]"]
  node_query_attrs["Query attributes"]
end

subgraph group_server["Database server"]
  node_sqlserver["SQL database server"]
  node_tx_inspection["Transaction inspection"]
  node_results["Query results"]
end

subgraph group_components["Server components"]
  node_conn_control["Connection control"]
  node_replication["Group replication"]
  node_resource_queries["Resource queries"]
  node_telemetry["Telemetry<br/>[tm_component.cc]"]
  node_audit["Audit events"]
  node_backup["Backup<br/>[mysqlbackup.cc]"]
end

subgraph group_security["Key management"]
  node_keyring["File keyring<br/>[keyring_file.cc]"]
  node_keyring_meta["Keyring metadata"]
  node_keyring_store[("Keyring data files<br/>[backend.cc]")]
end

subgraph group_router["Router REST services"]
  node_mrs_db["REST metadata queries"]
  node_mrs_changes["REST change queries"]
  node_metadata_db[("REST metadata database")]
end

node_user(("Database user"))

node_user -->|"submits SQL"| node_mysql_cli
node_user -->|"requests export"| node_dump
node_user -->|"provides data"| node_import
node_user -->|"requests administration"| node_admin
node_user -->|"requests binlog work"| node_binlog
node_mysql_cli -->|"sends queries"| node_sqlserver
node_dump -->|"reads data"| node_sqlserver
node_import -->|"loads data"| node_sqlserver
node_admin -->|"sends commands"| node_sqlserver
node_binlog -->|"accesses server"| node_sqlserver
node_sqlserver -->|"returns results"| node_results
node_sqlserver -->|"inspects transactions"| node_tx_inspection
node_mysql_cli -->|"binds attributes"| node_query_attrs
node_replication -->|"runs report queries"| node_resource_queries
node_resource_queries -->|"executes SQL"| node_sqlserver
node_sqlserver -->|"uses connection control"| node_conn_control
node_sqlserver -->|"emits telemetry"| node_telemetry
node_sqlserver -->|"emits audit events"| node_audit
node_backup -->|"backs up server"| node_sqlserver
node_keyring -->|"exposes metadata"| node_keyring_meta
node_keyring -->|"reads and writes"| node_keyring_store
node_mrs_db -->|"queries metadata"| node_metadata_db
node_mrs_changes -->|"queries changes"| node_metadata_db

click node_mysql_cli "https://github.com/mysql/mysql-server/blob/trunk/client/mysql.cc"
click node_dump "https://github.com/mysql/mysql-server/blob/trunk/client/mysqldump.cc"
click node_import "https://github.com/mysql/mysql-server/blob/trunk/client/mysqlimport.cc"
click node_admin "https://github.com/mysql/mysql-server/blob/trunk/client/mysqladmin.cc"
click node_binlog "https://github.com/mysql/mysql-server/blob/trunk/client/mysqlbinlog.cc"
click node_sqlserver "https://github.com/mysql/mysql-server/tree/trunk/sql/server_component"
click node_tx_inspection "https://github.com/mysql/mysql-server/blob/trunk/sql/server_component/ongoing_transaction_query_service.cc"
click node_query_attrs "https://github.com/mysql/mysql-server/blob/trunk/client/client_query_attributes.cc"
click node_conn_control "https://github.com/mysql/mysql-server/blob/trunk/components/connection_control/connection_control.cc"
click node_replication "https://github.com/mysql/mysql-server/blob/trunk/components/group_replication_resource_manager/resource_manager.cc"
click node_resource_queries "https://github.com/mysql/mysql-server/blob/trunk/components/group_replication_resource_manager/resource_manager_query.cc"
click node_telemetry "https://github.com/mysql/mysql-server/blob/trunk/components/telemetry/tm_component.cc"
click node_audit "https://github.com/mysql/mysql-server/blob/trunk/components/audit_api_message_emit/audit_api_message_emit.cc"
click node_backup "https://github.com/mysql/mysql-server/blob/trunk/components/mysqlbackup/mysqlbackup.cc"
click node_keyring "https://github.com/mysql/mysql-server/blob/trunk/components/keyrings/keyring_file/keyring_file.cc"
click node_keyring_meta "https://github.com/mysql/mysql-server/blob/trunk/components/keyrings/keyring_file/service_implementation/keyring_metadata_query_service_definition.cc"
click node_keyring_store "https://github.com/mysql/mysql-server/blob/trunk/components/keyrings/keyring_file/backend/backend.cc"
click node_mrs_db "https://github.com/mysql/mysql-server/blob/trunk/router/src/mysql_rest_service/src/mrs/database/query_entries_db_service.cc"
click node_mrs_changes "https://github.com/mysql/mysql-server/blob/trunk/router/src/mysql_rest_service/include/mrs/database/query_changes_db_service.h"
click node_results "https://github.com/mysql/mysql-server/tree/trunk/sql/server_component"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_mysql_cli,node_dump,node_import,node_admin,node_binlog,node_query_attrs toneBlue
class node_sqlserver,node_tx_inspection,node_results,node_user toneAmber
class node_conn_control,node_replication,node_resource_queries,node_telemetry,node_audit,node_backup toneMint
class node_keyring,node_keyring_meta,node_keyring_store toneRose
class node_mrs_db,node_mrs_changes,node_metadata_db toneIndigo
```

## Components

### Client tools

- [SQL client](https://github.com/mysql/mysql-server/blob/trunk/client/mysql.cc): `client/mysql.cc`
- [Dump and export](https://github.com/mysql/mysql-server/blob/trunk/client/mysqldump.cc): `client/mysqldump.cc`
- [Data import](https://github.com/mysql/mysql-server/blob/trunk/client/mysqlimport.cc): `client/mysqlimport.cc`
- [Administration tools](https://github.com/mysql/mysql-server/blob/trunk/client/mysqladmin.cc): `client/mysqladmin.cc`
- [Binlog tools](https://github.com/mysql/mysql-server/blob/trunk/client/mysqlbinlog.cc): `client/mysqlbinlog.cc`
- [Query attributes](https://github.com/mysql/mysql-server/blob/trunk/client/client_query_attributes.cc): `client/client_query_attributes.cc`

### Database server

- [SQL database server](https://github.com/mysql/mysql-server/tree/trunk/sql/server_component): `sql/server_component`
- [Transaction inspection](https://github.com/mysql/mysql-server/blob/trunk/sql/server_component/ongoing_transaction_query_service.cc): `sql/server_component/ongoing_transaction_query_service.cc`
- [Query results](https://github.com/mysql/mysql-server/tree/trunk/sql/server_component): `sql/server_component`

### Server components

- [Connection control](https://github.com/mysql/mysql-server/blob/trunk/components/connection_control/connection_control.cc): `components/connection_control/connection_control.cc`
- [Group replication](https://github.com/mysql/mysql-server/blob/trunk/components/group_replication_resource_manager/resource_manager.cc): `components/group_replication_resource_manager/resource_manager.cc`
- [Resource queries](https://github.com/mysql/mysql-server/blob/trunk/components/group_replication_resource_manager/resource_manager_query.cc): `components/group_replication_resource_manager/resource_manager_query.cc`
- [Telemetry](https://github.com/mysql/mysql-server/blob/trunk/components/telemetry/tm_component.cc): `components/telemetry/tm_component.cc`
- [Audit events](https://github.com/mysql/mysql-server/blob/trunk/components/audit_api_message_emit/audit_api_message_emit.cc): `components/audit_api_message_emit/audit_api_message_emit.cc`
- [Backup](https://github.com/mysql/mysql-server/blob/trunk/components/mysqlbackup/mysqlbackup.cc): `components/mysqlbackup/mysqlbackup.cc`

### Key management

- [File keyring](https://github.com/mysql/mysql-server/blob/trunk/components/keyrings/keyring_file/keyring_file.cc): `components/keyrings/keyring_file/keyring_file.cc`
- [Keyring metadata](https://github.com/mysql/mysql-server/blob/trunk/components/keyrings/keyring_file/service_implementation/keyring_metadata_query_service_definition.cc): `components/keyrings/keyring_file/service_implementation/keyring_metadata_query_service_definition.cc`
- [Keyring data files](https://github.com/mysql/mysql-server/blob/trunk/components/keyrings/keyring_file/backend/backend.cc): `components/keyrings/keyring_file/backend/backend.cc`

### Router REST services

- [REST metadata queries](https://github.com/mysql/mysql-server/blob/trunk/router/src/mysql_rest_service/src/mrs/database/query_entries_db_service.cc): `router/src/mysql_rest_service/src/mrs/database/query_entries_db_service.cc`
- [REST change queries](https://github.com/mysql/mysql-server/blob/trunk/router/src/mysql_rest_service/include/mrs/database/query_changes_db_service.h): `router/src/mysql_rest_service/include/mrs/database/query_changes_db_service.h`
- **REST metadata database**

### Other components

- **Database user**

## Connections

- Database user → SQL client: submits SQL
- Database user → Dump and export: requests export
- Database user → Data import: provides data
- Database user → Administration tools: requests administration
- Database user → Binlog tools: requests binlog work
- SQL client → SQL database server: sends queries
- Dump and export → SQL database server: reads data
- Data import → SQL database server: loads data
- Administration tools → SQL database server: sends commands
- Binlog tools → SQL database server: accesses server
- SQL database server → Query results: returns results
- SQL database server → Transaction inspection: inspects transactions
- SQL client → Query attributes: binds attributes
- Group replication → Resource queries: runs report queries
- Resource queries → SQL database server: executes SQL
- SQL database server → Connection control: uses connection control
- SQL database server → Telemetry: emits telemetry
- SQL database server → Audit events: emits audit events
- Backup → SQL database server: backs up server
- File keyring → Keyring metadata: exposes metadata
- File keyring → Keyring data files: reads and writes
- REST metadata queries → REST metadata database: queries metadata
- REST change queries → REST metadata database: queries changes
