mysql_database
A database in the MySQL or MariaDB server on the host, managed through the mysql client as root over the server’s socket. Settings left unset are left as they are.
Use mysql_database to make an application’s database in the MySQL or MariaDB server on a host. Conn3x runs the mysql client on the host as root, so nothing on your machine needs a database driver or a route to port 3306.
Example usage
Section titled “Example usage”A database with the character set most apps want:
step "app_db" { mysql_database { name = "app" charset = "utf8mb4" collation = "utf8mb4_unicode_ci" }}Drop it when the step is removed:
step "scratch_db" { mysql_database { name = "scratch" on_remove = "delete" }}Arguments
Section titled “Arguments”| Name | Type | Required | Description |
|---|---|---|---|
charset |
string | No | Default character set, such as utf8mb4. Changing it changes the default for new tables only. |
collation |
string | No | Default collation, such as utf8mb4_unicode_ci. Changing it changes the default for new tables only. |
name |
string | Yes | Database name, up to 64 characters. Renaming makes a new database; the old one stays unless on_remove is “delete”. |
on_remove |
string | No | What happens on the host when this resource is removed: “forget” (default) leaves the database, “delete” drops it and everything in it. |
Read-only attributes
Section titled “Read-only attributes”Conn3x sets these; reference them as conn3x_mysql_database.<circuit>__<step>["<host>"].<name>.
| Name | Type | Description |
|---|---|---|
in_sync |
bool | Whether the database matched at the last refresh. |
revision |
string | Changes each time Conn3x changes this on the host. Handlers watch it. |
A step lowers to the conn3x_mysql_database resource, one instance per host, and connects with its circuit’s ssh block.
How it works
Section titled “How it works”What the host needs. MySQL or MariaDB has to be installed and running. Conn3x logs in as root over the server’s socket, which is how both servers set up root at install, so set become = true in the circuit’s ssh block unless you log in as root. Every statement goes to the client on stdin, never on a command line.
Character set and collation. Leave them unset and a new database gets the server’s defaults, and an existing one keeps its own. Changing either one runs ALTER DATABASE, which changes the default for tables made afterwards. Tables already there keep theirs.
Changes. Changing name makes a new database, and on_remove decides what happens to the old one.
Removal
Section titled “Removal”When you delete a mysql_database step, on_remove decides what happens on the host. The default, "forget", leaves the database. "delete" drops it and every table in it. Conn3x never drops mysql, information_schema, performance_schema or sys.