Usage: ./scripts/mysql_install_db [OPTIONS] --basedir=path The path to the MySQL 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 MySQL system tables on a different host than the target. --datadir=path The path to the MySQL data directory. If missing, the directory will be created, but its parent directory must already exist and be writable. --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 MySQL data directory. Same as --datadir. --no-defaults Don't read default options from any option file. --keep-my-cnf Don't try to create my.cnf based on template. Useful for systems with working, updated my.cnf. Deprecated, will be removed in future version. --random-passwords Create and set a random password for all root accounts and set the "password expired" flag, also remove the anonymous accounts. --rpm For internal use. This option is used by RPM files during the MySQL 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 MySQL source directory. This option uses the compiled binaries and support files within the source tree, useful for if you don't want to install MySQL 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. 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. Any other options are passed to the mysqld program.
若出现以下情况:
1 2
FATAL ERROR: please install the following Perl modules before executing ./scripts/mysql_install_db: Data::Dumper
则执行perl-Data-Dumper的安装
1
yum install perl-Data-Dumper
4. 创建MySQL组和用户
1 2
groupadd mysql useradd -M -s /sbin/nologin mysql -g mysql
2018-01-18 17:31:30 [WARNING] mysql_install_db is deprecated. Please consider switching to mysqld --initialize 2018-01-18 17:31:30 [ERROR] The data directory needs to be specified.
# For advice on how to change settings please see # http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html
[client] default-character-set = utf8mb4
[mysqld]
# Remove leading # and set to the amount of RAM for the most important data # cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%. # innodb_buffer_pool_size = 128M
# Remove leading # to turn on a very important data integrity option: logging # changes to the binary log between backups. # log_bin
# These are commonly set, remove the # and set as required. basedir = /usr/local/mysql/ datadir = /usr/local/mysql/data/ port = 3306 # server_id = ..... # socket = ..... # 忽略大小写 lower_case_table_names = 1 # 默认编码 character_set_server = utf8mb4 init_connect = 'SET NAMES utf8mb4'
# Remove leading # to set options mainly useful for reporting servers. # The server defaults are faster for transactions and fast SELECTs. # Adjust sizes as needed, experiment to find the optimal values. # join_buffer_size = 128M # sort_buffer_size = 2M # read_rnd_buffer_size = 2M
[mysqld] # Remove leading # and set to the amount of RAM for the most important data # cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%. # innodb_buffer_pool_size = 128M
# Remove leading # to turn on a very important data integrity option: logging # changes to the binary log between backups. # log_bin
# These are commonly set, remove the # and set as required. basedir = /usr/local/mysql datadir = /usr/local/mysql/data port = 3360 # server_id = ..... socket = /usr/local/mysql/data/mysql.sock pid_file = /usr/local/mysql/data/mysql.pid # 忽略大小写 lower_case_table_names = 1 # 默认编码 character_set_server = utf8mb4 init_connect = 'SET NAMES utf8mb4'
# 开启查询缓存 # 针对警告"TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option",版本5.7 explicit_defaults_for_timestamp=true
# Remove leading # to set options mainly useful for reporting servers. # The server defaults are faster for transactions and fast SELECTs. # Adjust sizes as needed, experiment to find the optimal values. # join_buffer_size = 128M # sort_buffer_size = 2M # read_rnd_buffer_size = 2M
which will also give you the option of removing the test databases and anonymous user created by default. This is strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
cd . ; /usr/local/mysql/bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd mysql-test ; perl mysql-test-run.pl
Please report any problems at http://bugs.mysql.com/
The latest information about MySQL is available on the web at
http://www.mysql.com
Support MySQL by buying support/licenses at http://shop.mysql.com
WARNING: Found existing config file /usr/local/mysql/my.cnf on the system. Because this file might be in use, it was not replaced, but was used in bootstrap (unless you used --defaults-file) and when you later start the server. The new default config file was created as /usr/local/mysql/my-new.cnf, please compare it with your file and take the changes you need.