0

start mysql server as root failed.

1.service mysqld start

Starting mysqld:                                           [FAILED]

2.mysqld error log:

2016-02-23T01:19:16.961857Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).

2016-02-23T01:19:16.963350Z 0 [Note] mysqld (mysqld 5.7.10) starting as process 20924 ...

2016-02-23T01:19:16.965669Z 0 [ERROR] Fatal error: Please read "Security" section of the manual to find out how to run mysqld as root!

2016-02-23T01:19:16.965715Z 0 [ERROR] Aborting

2016-02-23T01:19:16.965737Z 0 [Note] Binlog end

2016-02-23T01:19:16.965818Z 0 [Note] mysqld: Shutdown complete

but can start mysql service as mysql user, or use mysqld_safe as root can start too. what's wrong?

/etc/init.d/msyqld start

MySQL Daemon failed to start.

Starting mysqld: [FAILED]

if ! /bin/kill -0 $safe_pid 2>/dev/null; then
    echo "MySQL Daemon failed to start."
    ret=1
    break
fi
... ...
if [ $ret -eq 0 ]; then
    action $"Starting $prog: " /bin/true
    touch $lockfile
else
    action $"Starting $prog: " /bin/false
fi

I found this Code Snippets in the script /etc/init.d/mysqld. but don't know why?

aduan
  • 27
  • 2
  • 7

3 Answers3

0

Add this line to /etc/my.cnf in [mysqld] section

explicit_defaults_for_timestamp = 1

Check this link

  • 1
    after add this have not warnning log, but still can not start mysql server, the same error log – aduan Feb 23 '16 at 03:21
0

Since you can start as the mysql user, it is likely you have it currently configured to run as root.

Mysql's reference manual says:

On Linux, for installations performed using a MySQL repository, RPM packages, or Debian packages, the MySQL server mysqld should be started by the local mysql operating system user. Starting by another operating system user is not supported by the init scripts that are included as part of the installation.

Dan Bowling
  • 1,205
  • 1
  • 15
  • 41
-1
/etc/selinux/config

#SELINUX=enforcing
SELINUX=disabled
aduan
  • 27
  • 2
  • 7
  • 2
    Can you explain this answer a bit (popped up in Review)? Thanks. – Will Feb 24 '16 at 02:46
  • 2
    Setting selinux to disabled is significant security implications. If this works, it usually means that you were violating a best practice. Either re-evaluating the configuration is a much safer route forward. It could also very well be related to this: https://stackoverflow.com/a/53164165/238322 – Dan Bowling Nov 06 '18 at 00:25