1、Please read "Security" section of the manual to find out how to run mysqld as root!
[root@172-19-5-17 sbin]# mysqld
2019-03-14T12:02:36.052561Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2019-03-14T12:02:36.056858Z 0 [Note] mysqld (mysqld 5.7.23) starting as process 28121 ...
2019-03-14T12:02:36.058426Z 0 [ERROR] Fatal error: Please read "Security" section of the manual to find out how to run mysqld as root!
原因:
mysqld默认拒绝用户使用root帐户启动,但root用户可以通过在命令后面加上"--user=root"选项来强行启动mysqld。
与使用root用户启动mysqld相比,更好的方法是使用一个普通的、没有高级权限的用户帐户允许mysqld,例如创建一个名为mysql的用户帐户来专门管理MySQL。使用其帐启动MySQL的方法是在mysqld命令后面加上一个用户选项,这个用户属于mysqld用户组并且位于my.cnf配置文件中。例如在创建mysql帐户后,可以将下面的内容添加到/etc/my.cnf文件中:
[mysqld]
user=mysql
这个选项可以使你使用指定的用户帐户启动MySQL,无论是mysqld_safe还是mysql.server命令,都可以使用。
2、TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
解决:在 vi /etc/my.cnf 文件中加上 : explicit_defaults_for_timestamp=true 。保存后再次启动就可以了。
3、下面是通过查看的日志:
[root@172-19-5-17 sbin]# sudo service mysqld start
Redirecting to /bin/systemctl start mysqld.service
Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" for details.
[root@172-19-5-17 sbin]# sudo service mysqld status
Redirecting to /bin/systemctl status mysqld.service
● mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: deactivating (final-sigterm) (Result: exit-code)
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 9795 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=1/FAILURE)
Process: 9766 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
CGroup: /system.slice/mysqld.service
└─9797 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid
Mar 15 09:19:39 172-19-5-17 systemd[1]: Starting MySQL Server...
Mar 15 09:19:40 172-19-5-17 mysqld_pre_systemd[9766]: 2019-03-15T01:19:40.295147Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see docume...r more details).
Mar 15 09:19:40 172-19-5-17 mysqld_pre_systemd[9766]: 2019-03-15T01:19:40.296861Z 0 [ERROR] --initialize specified but the data directory has files in it. Aborting.
Mar 15 09:19:40 172-19-5-17 mysqld_pre_systemd[9766]: 2019-03-15T01:19:40.296897Z 0 [ERROR] Aborting
Mar 15 09:19:40 172-19-5-17 mysqld[9795]: Initialization of mysqld failed: 0
Mar 15 09:19:40 172-19-5-17 systemd[1]: mysqld.service: control process exited, code=exited status=1
Hint: Some lines were ellipsized, use -l to show in full.
解决:参考官方提供的文档解决的,https://dev.mysql.com/doc/mysql-secure-deployment-guide/8.0/en/secure-deployment-post-install.html