Create, read, and update a Linode MySQL database.
| Field | Type | Required | Description |
|---|---|---|---|
api_token |
str |
Required | The Linode account personal access token. It is necessary to run the module. It can be exposed by the environment variable LINODE_API_TOKEN instead. See details in Usage. |
- name: Create a basic MySQL database
linode.cloud.database_mysql_v2:
label: my-db
region: us-mia
engine: mysql/8
type: g6-nanode-1
allow_list:
- 0.0.0.0/0
state: present- name: Create a MySQL database with three nodes
linode.cloud.database_mysql_v2:
label: my-db
region: us-mia
engine: mysql/8
type: g6-standard-1
cluster_size: 3
allow_list:
- 0.0.0.0/0
state: present- name: Create a MySQL database with an explicit maintenance schedule and engine configuration
linode.cloud.database_mysql_v2:
label: my-db
region: us-mia
engine: mysql/8
type: g6-nanode-1
engine_config:
binlog_retention_period: 600
mysql:
connect_timeout: 20
updates:
duration: 4
frequency: weekly
hour_of_day: 16
day_of_week: 4
state: present- name: Create a MySQL database forked from another database
linode.cloud.database_mysql_v2:
label: my-db
region: us-mia
engine: mysql/8
type: g6-nanode-1
fork:
source: 12345
state: present- name: Create a MySQL database attached to a VPC
linode.cloud.database_mysql_v2:
label: my-db
region: us-mia
engine: mysql/8
type: g6-nanode-1
private_network:
vpc_id: 123
subnet_id: 456
public_access: true
state: present- name: Delete a MySQL database
linode.cloud.database_mysql_v2:
label: my-db
state: absent| Field | Type | Required | Description |
|---|---|---|---|
state |
str |
Required | The desired state of the Managed Database. (Choices: resume, suspend, present, absent) |
allow_list |
list |
Optional | A list of IP addresses and CIDR ranges that can access the Managed Database. (Updatable) |
cluster_size |
int |
Optional | The number of Linode instance nodes deployed to the Managed Database. (Updatable) |
engine |
str |
Optional | The Managed Database engine in engine/version format. (Updatable) |
engine_config (sub-options) |
dict |
Optional | Various parameters used to configure this database's underlying engine. NOTE: If a configuration parameter is not current accepted by this field, configure using the linode.cloud.api_request module. (Updatable) |
label |
str |
Optional | The label of the Managed Database. |
detach_private_network |
bool |
Optional | If true, the Managed Database will be detached from its current private network when private_network is null. If the Managed Database is not currently attached to a private network or the private_network field is specified, this option has no effect. This is not necessary when switching between VPC subnets. (Default: False) |
private_network (sub-options) |
dict |
Optional | Restricts access to this database using a virtual private cloud (VPC) that you've configured in the region where the database will live. (Updatable) |
region |
str |
Optional | The region of the Managed Database. |
type |
str |
Optional | The Linode Instance type used by the Managed Database for its nodes. (Updatable) |
fork (sub-options) |
dict |
Optional | Information about a database to fork from. |
updates (sub-options) |
dict |
Optional | Configuration settings for automated patch update maintenance for the Managed Database. (Updatable) |
wait_timeout |
int |
Optional | The maximum number of seconds a poll operation can take before raising an error. (Default: 2700) |
| Field | Type | Required | Description |
|---|---|---|---|
mysql (sub-options) |
dict |
Optional | MySQL specific configuration fields. |
binlog_retention_period |
int |
Optional | The minimum amount of time in seconds to keep binlog entries before deletion. This may be extended for use cases like MySQL Debezium Kafka connector. |
| Field | Type | Required | Description |
|---|---|---|---|
connect_timeout |
int |
Optional | The number of seconds that the mysqld server waits for a connect packet before responding with Bad handshake. |
default_time_zone |
str |
Optional | Default server time zone as an offset from UTC (from -12:00 to +12:00), a time zone name, or 'SYSTEM' to use the MySQL server default. |
group_concat_max_len |
int |
Optional | The maximum permitted result length in bytes for the GROUP_CONCAT() function. |
information_schema_stats_expiry |
int |
Optional | The time, in seconds, before cached statistics expire. |
innodb_change_buffer_max_size |
int |
Optional | Maximum size for the InnoDB change buffer, as a percentage of the total size of the buffer pool. |
innodb_flush_neighbors |
int |
Optional | Specifies whether flushing a page from the InnoDB buffer pool also flushes other dirty pages in the same extent. |
innodb_ft_min_token_size |
int |
Optional | Minimum length of words that are stored in an InnoDB FULLTEXT index. |
innodb_ft_server_stopword_table |
str |
Optional | This option is used to specify your own InnoDB FULLTEXT index stopword list for all InnoDB tables. |
innodb_lock_wait_timeout |
int |
Optional | The length of time in seconds an InnoDB transaction waits for a row lock before giving up. |
innodb_log_buffer_size |
int |
Optional | The size in bytes of the buffer that InnoDB uses to write to the log files on disk. |
innodb_online_alter_log_max_size |
int |
Optional | The upper limit in bytes on the size of the temporary log files used during online DDL operations for InnoDB tables. |
innodb_read_io_threads |
int |
Optional | The number of I/O threads for read operations in InnoDB. |
innodb_rollback_on_timeout |
bool |
Optional | When enabled a transaction timeout causes InnoDB to abort and roll back the entire transaction. |
innodb_thread_concurrency |
int |
Optional | Defines the maximum number of threads permitted inside of InnoDB. |
innodb_write_io_threads |
int |
Optional | The number of I/O threads for write operations in InnoDB. |
interactive_timeout |
int |
Optional | The number of seconds the server waits for activity on an interactive connection before closing it. |
internal_tmp_mem_storage_engine |
str |
Optional | The storage engine for in-memory internal temporary tables. (Choices: TempTable, MEMORY) |
max_allowed_packet |
int |
Optional | Size of the largest message in bytes that can be received by the server. Default is 67108864 (64M). |
max_heap_table_size |
int |
Optional | Limits the size of internal in-memory tables. Also set tmp_table_size. Default is 16777216 (16M). |
net_buffer_length |
int |
Optional | Start sizes of connection buffer and result buffer. Default is 16384 (16K). |
net_read_timeout |
int |
Optional | The number of seconds to wait for more data from a connection before aborting the read. |
net_write_timeout |
int |
Optional | The number of seconds to wait for a block to be written to a connection before aborting the write. |
sort_buffer_size |
int |
Optional | Sort buffer size in bytes for ORDER BY optimization. Default is 262144 (256K). |
sql_mode |
str |
Optional | Global SQL mode. Set to empty to use MySQL server defaults. |
sql_require_primary_key |
bool |
Optional | Require primary key to be defined for new tables or old tables modified with ALTER TABLE and fail if missing. |
tmp_table_size |
int |
Optional | Limits the size of internal in-memory tables. Also sets max_heap_table_size. Default is 16777216 (16M). |
wait_timeout |
int |
Optional | The number of seconds the server waits for activity on a noninteractive connection before closing it. |
| Field | Type | Required | Description |
|---|---|---|---|
vpc_id |
int |
Required | The ID of the virtual private cloud (VPC) to restrict access to this database using |
subnet_id |
int |
Required | The ID of the VPC subnet to restrict access to this database using. |
public_access |
bool |
Optional | Set to true to allow clients outside of the VPC to connect to the database using a public IP address. (Default: False) |
| Field | Type | Required | Description |
|---|---|---|---|
restore_time |
str |
Optional | The database timestamp from which it was restored. |
source |
int |
Optional | The instance id of the database that was forked from. |
| Field | Type | Required | Description |
|---|---|---|---|
day_of_week |
int |
Required | The day to perform maintenance. 1=Monday, 2=Tuesday, etc. (Choices: 1, 2, 3, 4, 5, 6, 7) |
duration |
int |
Required | The maximum maintenance window time in hours. |
hour_of_day |
int |
Required | The hour to begin maintenance based in UTC time. |
frequency |
str |
Optional | The frequency at which maintenance occurs. (Choices: weekly; Default: weekly) |
-
database- The database in JSON serialized form.- Sample Response:
{ "allow_list": [ "10.0.0.3/32" ], "cluster_size": 3, "created": "2025-02-10T20:10:20", "encrypted": true, "engine": "mysql", "engine_config": { "binlog_retention_period": 600, "mysql": { "connect_timeout": 20 } }, "hosts": { "primary": "a225891-akamai-prod-1798333-default.g2a.akamaidb.net", "standby": "replica-a225891-akamai-prod-1798333-default.g2a.akamaidb.net" }, "id": 12345, "label": "my-db", "members": { "172.104.207.136": "primary", "194.195.112.177": "failover", "45.79.126.72": "failover" }, "oldest_restore_time": "2025-02-10T20:15:07", "platform": "rdbms-default", "port": 11876, "private_network": { "public_access": true, "subnet_id": 456, "vpc_id": 123 }, "region": "ap-west", "ssl_connection": true, "status": "active", "total_disk_size_gb": 30, "type": "g6-standard-1", "updated": "2025-02-10T20:25:55", "updates": { "day_of_week": 4, "duration": 4, "frequency": "weekly", "hour_of_day": 16, "pending": [] }, "used_disk_size_gb": 0, "version": "8.0.35" } - See the Linode API response documentation for a list of returned fields
- Sample Response:
-
ssl_cert- The SSL CA certificate for an accessible Managed MySQL Database.- Sample Response:
{ "ca_certificate": "LS0tLS1CRUdJ...==" } - See the Linode API response documentation for a list of returned fields
- Sample Response:
-
credentials- The root username and password for an accessible Managed MySQL Database.- Sample Response:
{ "password": "s3cur3P@ssw0rd", "username": "akmadmin" } - See the Linode API response documentation for a list of returned fields
- Sample Response: