mariadb-install-db
Initialize the MariaDB data directory
TLDR
Initialize a database
Display help
SYNOPSIS
mariadb-install-db [options]
PARAMETERS
--auth-root-authentication-method=[legacy|socket]
Select authentication method for root. With 'legacy', the root user will authenticate with a password. With 'socket', authentication will be performed using the unix socket.
--basedir=path
The base directory where MariaDB is installed.
--datadir=path
The data directory where MariaDB databases are stored.
--db-bootstrap
Bootstrap a new cluster, to be the first server of the cluster.
--defaults-file=file
Read options from the given file only.
--force
Force execution even if the data directory already exists. Use with caution!
--help
Display help message and exit.
--ldata=path
Synonym for --datadir. Deprecated.
--log-error=file
File to write error messages.
--no-defaults
Don't read default options from any option file.
--no-dd-upgrade
Do not perform a data dictionary upgrade if it is needed.
--no-se-range-optimizer
Disable the storage engine range optimizer, mainly for debugging.
--plugin-dir=path
The directory where MariaDB plugins are located.
--service=name
Create a systemd service file to start the server. This is automatically executed when installing from a package management system.
--skip-auth-table-grant
Skip creating the auth tables. This is useful only for special cases, when creating user tables will be done otherwise.
--skip-create-tables
Skip creation of the MariaDB tables.
Implies --skip-auth-table-grant.
--socket=path
The socket file to use for local connections.
--ssl
Create SSL certificates.
--ssl-ca=file
The CA file to use for SSL certificates.
--ssl-cert=file
The certificate file to use for SSL certificates.
--ssl-key=file
The key file to use for SSL certificates.
--sysconfdir=path
The directory where MariaDB configuration files are located.
--tmpdir=path
The temporary directory to use.
--user=user_name
The user account that the MariaDB server will run as.
--verbose
More verbose output.
--wsrep-new-cluster
Bootstrap a new Galera cluster, to be the first server of the cluster.
DESCRIPTION
The `mariadb-install-db` command initializes the MariaDB data directory. This command is crucial for setting up a new MariaDB installation or when you need to re-initialize your data directory. It performs several important tasks including: creating the system tables (mysql, performance_schema, and information_schema), setting up the initial MariaDB users (including root), and generating the SSL certificates for secure connections.
Before MariaDB 10.4.3, `mariadb-install-db` was a Perl script. From MariaDB 10.4.3 onwards, it's a binary program which significantly improves performance and security. The script approach had security vulnerabilities that the binary resolves. Because `mariadb-install-db` directly modifies the file system, it's vital to run this command with appropriate user privileges, usually as the user under which the MariaDB server will run (typically `mysql`). Failing to initialize the database can cause MariaDB to fail to start, or behave unpredictably. This tool provides a secure and performant way to create and setup the data directory and its essential privileges.
CAVEATS
Running `mariadb-install-db` with the `--force` option can potentially overwrite existing data.
Always backup your data before attempting to re-initialize your MariaDB data directory.
Ensure the user specified with `--user` has the necessary permissions to create and modify files in the data directory.
PERMISSIONS
It's crucial that `mariadb-install-db` is executed with the correct user permissions, ideally the same user that will run the MariaDB server daemon. Otherwise, file ownership issues can prevent the server from starting correctly.
DATA DICTIONARY UPGRADE
When upgrading MariaDB, it might be necessary to upgrade the data dictionary. By default, `mariadb-install-db` will attempt to do so. If you wish to prevent this, you can use the `--no-dd-upgrade` option. Usually is a sign that you may need to run `mysql_upgrade` command.
HISTORY
Prior to MariaDB 10.4.3, `mariadb-install-db` was implemented as a Perl script. This script had some performance and security limitations. From MariaDB 10.4.3 onwards, it's been re-written as a binary program using C++, significantly improving performance and security. This change addresses the vulnerabilities in the script version and provides a more robust solution for initializing the database.
SEE ALSO
mariadbd(1), mysql(1), mysqladmin(1)