[root@localhost scripts]# ll total 16 -rwxr-xr-x 1 root mysql 16168 Feb 24 11:08 mysql_install_db
[root@localhost scripts]# scripts/mysql_install_db --help Usage: ./mysql_install_db [OPTIONS] --basedir=path The path to the MariaDB installation directory. --builddir=path If using --srcdir with out-of-directory builds, you will need to set this to the location of the build directory where built files reside. --cross-bootstrap For internal use. Used when building the MariaDB system tables on a different host than the target. --datadir=path The path to the MariaDB data directory. --defaults-extra-file=name Read this file after the global files are read. --defaults-file=name Only read default options from the given file name. --force 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. --help Display this help and exit. --ldata=path The path to the MariaDB data directory. Same as --datadir. --no-defaults Don‘t read default options from any option file. --defaults-file=path Read only this configuration file. --rpm For internal use. This option is used by RPM files during the MariaDB installation process. --skip-name-resolve Use IP addresses rather than hostnames when creating grant table entries. This option can be useful if your DNS does not work. --srcdir=path 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. --user=user_name The login username to use for running mysqld. Files and directories created by mysqld will be owned by this user.
上面两个选项很重要,定义了安装启动时用哪个用户登录并且数据库数据存放的目录在哪里
并且必须回到mysql目录下进行安装操作!因为它依赖bin/目录下的文件。执行如下:
[root@localhost mysql]# scripts/mysql_install_db --user=mysql --datadir=/mydata/data Installing MariaDB/MySQL system tables in ‘/mydata/data‘ ... OK