9、初始化MySQL
在5.7中,推荐使用mysqld --initialize对数据库进行初始化(mysql_install_db已经不再推荐使用),在初始化时如果加上--initialize-insecure,则会创建空密码的 root@localhost 账号,否则会创建带密码的 root@localhost 账号,密码直接写在 log-error 日志文件中
[root@gusha2 mysql]# cd bin/
[root@gusha2 bin]# mysqld --defaults-file=/etc/my.cnf --user=mysql --initialize --initialize-insecure
[root@gusha2 bin]# ls /data/dbwyzc/data/
auto.cnf ibdata1 ib_logfile1 performance_schema
ib_buffer_pool ib_logfile0 mysql sys
[root@gusha2 bin]# ls /data/dbwyzc/logs/
mysqld.log
[root@gusha2 bin]# cat /data/dbwyzc/logs/mysqld.log
2016-03-23T20:45:41.774933Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2016-03-23T20:45:43.665168Z 0 [Warning] InnoDB: New log files created, LSN=45790
2016-03-23T20:45:43.939168Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2016-03-23T20:45:44.025867Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 368bbcd5-f138-11e5-aad0-000c29f650ca.
2016-03-23T20:45:44.029664Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2016-03-23T20:45:44.031662Z 1 [Warning] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
10、添加使用service快速启动MySQL
[root@gusha2 bin]# cd ../
[root@gusha2 mysql]# ls support-files/
magic my-default.cnf mysqld_multi.server mysql-log-rotate mysql.server
[root@gusha2 mysql]# cp support-files/mysql.server /etc/init.d/mysql
[root@gusha2 mysql]# service mysql start
Starting MySQL. [ OK ]