1

I am trying to setup MySql 5.7 on CentOS 6.10. I've installed MySQL but when I try to run sudo service mysqld start, it is not starting. The error is

2018-11-05T17:14:57.569757Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-11-05T17:14:57.573328Z 0 [Note] mysqld (mysqld 5.7.24) starting as process 10355 ...
2018-11-05T17:14:57.575610Z 0 [ERROR] Fatal error: Please read "Security" section of the manual to find out how to run mysqld as root!

2018-11-05T17:14:57.575652Z 0 [ERROR] Aborting

2018-11-05T17:14:57.575671Z 0 [Note] Binlog end
2018-11-05T17:14:57.575741Z 0 [Note] mysqld: Shutdown complete

I guess it is something to do with selecting the user type as root but I'm not able to figure out what to do. Can someone help?Thanks in advance

pramesh
  • 1,914
  • 1
  • 19
  • 30

1 Answers1

1

It looks like mysqld is configured to run as the root user right now, which is not a recommended way for it to run--hence the hard warnings forcing you to change your configuration. You should instead run as the mysql user that was created for you when you installed the package.

You can see the user mysqld is set up to run under by looking in the [mysqld] section of my.cnf. It seems most likely you have user=root, or the command line flag of --user=root is being applied.

Best practice would be to configure it to use the non-privileged mysql user instead.


Relevant documentation:

The How to Run MySQL as a Normal User documentation page indicates that:

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.

MariaDB (a fork of MySQL) provides a documentation page called Running mysqld as root which indicates:

MariaDB should never normally be run as the system's root user (this is unrelated to the MariaDB root user). If it is, any user with the FILE privilege can create or modify any files on the server as root.

MariaDB will normally return the error Fatal error: Please read "Security" section of the manual to find out how to run mysqld as root! if you attempt to run mysqld as root. If you need to override this restriction for some reason, start mysqld with the user=root option.

Better practice, and the default in most situations, is to use a separate user, exclusively used for MariaDB. In most distributions, this user is called mysql.

Community
  • 1
  • 1
Dan Bowling
  • 1,205
  • 1
  • 15
  • 41
  • I've created new user mysql and replaced user=root by user=mysql. Cannot start mysqld.... – pramesh Nov 06 '18 at 04:39
  • Have you double checked the data directory permissions as well? And are you getting the same error in your MySQL log? – Dan Bowling Nov 06 '18 at 04:41
  • 1
    Permission was fine, issue was with ibdata1 file, reinstalled mysql and followed https://stackoverflow.com/a/48748685/3816285 working fine now – pramesh Nov 06 '18 at 05:57