1--- 2layout: docs 3page_title: MySQL - Storage Backends - Configuration 4sidebar_title: MySQL 5description: |- 6 The MySQL storage backend is used to persist Vault's data in a MySQL server or 7 cluster. 8--- 9 10# MySQL Storage Backend 11 12The MySQL storage backend is used to persist Vault's data in a [MySQL][mysql] 13server or cluster. 14 15- **High Availability** – the MySQL storage backend supports high availability. 16 Note that due to the way mysql locking functions work they are lost if a connection 17 dies. If you would like to not have frequent changes in your elected leader you 18 can increase interactive_timeout and wait_timeout MySQL config to much higher than 19 default which is set at 8 hours. 20 21- **Community Supported** – the MySQL storage backend is supported by the 22 community. While it has undergone review by HashiCorp employees, they may not 23 be as knowledgeable about the technology. If you encounter problems with them, 24 you may be referred to the original author. 25 26```hcl 27storage "mysql" { 28 username = "user1234" 29 password = "secret123!" 30 database = "vault" 31} 32``` 33 34## `mysql` Parameters 35 36- `address` `(string: "127.0.0.1:3306")` – Specifies the address of the MySQL 37 host. 38 39- `database` `(string: "vault")` – Specifies the name of the database. If the 40 database does not exist, Vault will attempt to create it. 41 42- `table` `(string: "vault")` – Specifies the name of the table. If the table 43 does not exist, Vault will attempt to create it. 44 45- `tls_ca_file` `(string: "")` – Specifies the path to the CA certificate to 46 connect using TLS. 47 48- `max_parallel` `(string: "128")` – Specifies the maximum number of concurrent 49 requests to MySQL. 50 51- `max_idle_connections` `(string: "0")` – Specifies the maximum number of idle 52 connections to the database. A zero uses value defaults to 2 idle connections 53 and a negative value disables idle connections. If larger than 54 `max_parallel` it will be reduced to be equal. 55 56- `max_connection_lifetime` `(string: "0")` – Specifies the maximum amount of 57 time in seconds that a connection may be reused. If <= 0s connections are reused forever. 58 59Additionally, Vault requires the following authentication information. 60 61- `username` `(string: <required>)` – Specifies the MySQL username to connect to 62 the database. 63 64- `password` `(string: <required>)` – Specifies the MySQL password to connect to 65 the database. 66 67### High Availability Parameters 68 69- `ha_enabled` `(string: "true")` - Specifies if high availability mode is 70 enabled. This is a boolean value, but it is specified as a string like "true" 71 or "false". 72 73- `lock_table` `(string: "vault_lock")` – Specifies the name of the table to 74 use for storing high availability information. By default, this is the name 75 of the `table` suffixed with `_lock`. If the table does not exist, Vault will 76 attempt to create it. 77 78## `mysql` Examples 79 80### Custom Database and Table 81 82This example shows configuring the MySQL backend to use a custom database and 83table name. 84 85```hcl 86storage "mysql" { 87 database = "my-vault" 88 table = "vault-data" 89 username = "user1234" 90 password = "pass5678" 91} 92``` 93 94[mysql]: https://dev.mysql.com 95