Home >Database >Mysql Tutorial >mysql_install_db - Initialize the MySQL data directory
mysql_install_db handles the initialization tasks that need to be performed on the MySQL server (that is, before mysqld is ready for use). It initializes the MySQL data directory and helps create the system tables it contains. It initializes the system tablespaces and related data structures required to manage InnoDB tables.
The current version of mysql_install_db will generate a MySQL deployment that is secure by default. It has the following mentioned features.
Create a single administrative account named "root"@"localhost" with a randomly generated password and mark it as expired.
Anonymous user account was not created.
A test database accessible to all users was not created.
A test database accessible to all users was not created.
>
The "--admin-xxx" option helps control the characteristics of administrative accounts.
The "--" random-password-file' option can be used to control random passwords The password has been written.
The "--insecure" option can be used to suppress random password generation.
If mysql_install_db can generate a random administrative password, it writes the password to a file and displays the file name.
Now let us understand the invoking syntax-
Change the location to the MySQL installation directory and use the syntax mentioned below-
shell> bin/mysql_install_db --datadir=path/to/datadir [other_options]
The --datadir option is mandatory. mysql_install_db creates the data directory, which should not exist. If the data directory already exists, an upgrade operation is being performed, not an installation operation. It should run mysql_upgrade instead of mysql_install_db. If the data directory does not exist but mysql_install_db fails, any partially created data directory should be deleted before running mysql_install_db again.
Because of the MySQL server, mysqld must access the data directory when it is later run, so the user should run mysql_install_db from the same system account used to run mysqld, or run it as root and specify the --user option to indicate The username under which mysqld is running.
The above is the detailed content of mysql_install_db - Initialize the MySQL data directory. For more information, please follow other related articles on the PHP Chinese website!