In my particular case, the error was appearing due to missing /var/log/mysql
with mysql-server
package 5.7.21-1 on Debian-based Linux distro. Having ran strace
and sudo /usr/sbin/mysqld --daemonize --pid-file=/run/mysqld/mysqld.pid
( which is what the systemd
service actually runs), it became apparent that the issue was due to this:
2019-01-01T09:09:22.102568Z 0 [ERROR] Could not open file '/var/log/mysql/error.log' for error logging: No such file or directory
I've recently removed contents of several directories in /var/log
so it was no surprise. The solution was to create the directory and make it owned by mysql
user as in
$ sudo mkdir /var/log/mysql
$ sudo chown -R mysql:mysql /var/log/mysql
Having done that I've happily logged in via sudo mysql -u root
and greeted with the old and familiar mysql>
prompt