Maria DB

Description

Create / delete database and db-user during package install / uninstall. The database name can be hard-coded, read from config file or given by the user from UI wizard. Package developer can decide if creating a corresponding db-user is needed or not.

  • Acquire(): Create database and db-user accroding to resource specification.
    • database: resource specification can specify what action to take if a database with the same name already exists:
      1. drop : Delete the existing database.
      2. skip : Ignore database creation, keep the existing database and conitinue installation.
      3. error: Return error and rollback. (Default: error)
    • db-user: Create db-user and grant access to the database according to the resource specification. The default db-user to create is '${package}'@'localhost'
  • Release(): Delete database and db-user accroding to the resource specification. Default is to keep the database and db-user.
  • During package upgrade, MariaDB worker provides the get_key_value method to obtain previously create database's name, and there will be no create / delete for database and db-user

Provider

MariaDB

Timing

FROM_PREINST_TO_PREUNINST

Environment Variables

Variable Since Description
SYNOPKG_DB_USER_RAND_PW 6.0-5920 The random password generated during datebase user creation.

Updatable

No

Syntax

((*) required)

"mysql-db": {
    "info": {
        "db-name": "<db name>",     (*)
        "conf": "<conf>",
        "key": "<key>"
    },
    "root-pw": "<db password>", (*)
    "create-db" : {
        "char-set": "<character-set>",
        "collate": "<collate>",
        "db-collision": "drop" | "skip" | "error"
    },
    "grant-user": {
        "user-name" : "<db username>",
        "host"      : "<db user host>",
        "user-pw"   : "<user password>",
        "rand-pw"   : true | false
    },
    "drop-db-uninst": true | false,
    "drop-user-uninst": true | false
}
Member Since Description
info 5.5.47-0062 Object, info of db-name. The priority of retrieving database's name is db-name > conf. Which means, if db-name is given, conf and key will be ignored.
db-name 5.5.47-0062 String, database name, can be given by UI wizard.
conf 5.5.47-0062 String, file containing the database name's key-value-pair.
key 5.5.47-0062 String, the key in conf file to look for db-name.
root-pw 5.5.47-0062 String, root password of MariaDB.
create-db 5.5.47-0062 Object, info of database. If does not exist, database will not be created during Acquire().
character-set 5.5.47-0062 String, database's CHARACTER SET. (default = utf8)
collate 5.5.47-0062 String, database's COLLATE. (default = utf8_unicode_ci)
db-collision 5.5.47-0062 String, action to take if the database exists. Can be drop/skip/error.
grant-user 5.5.47-0062 Object, info of db-user. If does not exist, db-user will not be created during Acquire().
user-name 5.5.47-0062 String, db-user name. (default = ${package})
host 5.5.47-0062 String, db-user's host. (defaults = localhost)
user-pw 5.5.47-0062 String, db-user's password. If empty or null, db-user's password will not be set. Overrides existing user's password.
rand-pw 5.5.47-0062 Boolean, whether to generate a random password. If set to true, the db-user will be given a random password and be passed to environment variable SYNOPKG_DB_USER_RAND_PW. If user-pw exists, this value will be ignored.
drop-db-uninst 5.5.47-0062 Boolean, whether to delete database during Release(). Can be given by UI wizard. (defaults = false)
drop-user-uninst 5.5.47-0062 Boolean, whether to delete db-user during Release(). Can be given by UI wizard. (defaults = false)

Example

"mysql-db": {
    "info": {
        "db-name": "wordpressblog"
    },
    "root-pw": "{{pkgwizard_mysql_password}}",
    "create-db" : {
        "db-collision": "skip"
    },
    "grant-user": {
        "user-name" : "wordpress"
    },
    "drop-db-uninst": "{{pkgwizard_remove_mysql}}",
    "drop-user-uninst": "{{pkgwizard_remove_mysql}}"
}