Installing System Tables (mysql_install_db)
mysql_install_db is needed to create the system tables in the 'mysql'
database directory. MariaDB uses these tables to manage user rights and provide
the data for the 'help' command in the mysql client.
The normal usage of it is:
mysql_install_db --user=mysql
Here is a list of the options mysql_install_db supports:
| The path to the MariaDB installation directory. |
| If using '' with out-of-directory builds, you will need to set this to the location of the build directory where built files reside. |
| For internal use. Used when building the MariaDB system tables on a different host than the target. |
| The path to the MariaDB data directory. |
| Causes mysql_install_db to run even if DNS does not work. In that case, grant table entries that normally use hostnames will use IP addresses. |
| The path to the MariaDB data directory. Same as ''. |
| Don't read any configuration files (my.cnf). |
| Read only this configuration file. |
| In addition to the given groups, read also groups with this suffix. |
| For internal use. This option is used by RPM files during the MariaDB installation process. |
| Use IP addresses rather than hostnames when creating grant table entries. This option can be useful if your DNS does not work. |
| The path to the MariaDB source directory. This option uses the compiled binaries and support files within the source tree, useful for if you don't want to install MariaDB yet and just want to create the system tables. |
| The login username to use for running mysqld. Files and directories created by mysqld will be owned by this user. You must be root to use this option. By default mysqld runs using your current login name and files and directories that it creates will be owned by you. |
| omits the anonymous user. |
| Creates a password-less root account. Currently on by default. (since 10.1) |
| creates the MariaDB root user with the name USER (defaults to 'root') and using unix socket authentication. This way, only that user has MariaDB root acces after install. (since 10.1) |
| The USER created as a socket authenticated SUPER user. Defaults to 'root' (since 10.1) |
mysql_install_db reads the my.cnf groups [mysqld] and
[mysql_install_db]. In MariaDB 5.2 (and later), mysql_install_db also
reads the my.cnf groups [mariadb] and [client-server].
mysql_install_db works by starting the mysqld server in
mode and sending commands to create the system tables and their content.--bootstrap
If mysql_install_db fails, you should examine the logs (*.err files) in the
data directory (the one specified with ) for a clue of what went
wrong.--datadir
You can also test that this is not a general fault of mysqld by starting mysqld with
mysqld --skip-grant --general-log
and use the mysql command line client tool
(often located at /usr/local/mysql/bin/mysql for tarball installations of
MariaDB) to connect to the mysql database and look at the grant tables:
shell> /usr/local/mysql/bin/mysql -u root mysql MariaDB [mysql]> show tables
Installing a binary tar distribution:
If you install a tar file in a non standard path, like your home directory, and
you already have a MariaDB / MySQL package installed, you may get conflicts
with the default my.cnf file under /etc/. This often results in permissions
errors.
The solution for this is to either execute the following command from the installation directory:
./scripts/mysql_install_db --no-defaults --basedir=. --datadir=data
or to specify your own config file (with the appropriate locations specified within it):
./scripts/mysql_install_db --defaults-file=~/.my.cnf
See also:
- mysql_install_db
- The Windows version of
mysql_install_db:mysql_install_db.exe