Failed to start MySQL Community Server

The errors you got on the console when running mysqld directly include:

2019-08-31T12:51:57.597359Z 0 [ERROR] Failed to access directory for --secure-file-priv. Please make sure that directory exists and is accessible by MySQL Server. Supplied value : /var/lib/mysql-files

That's your problem.

To resolve it, first check the user that your mysqld is attempting to run as; this will be the user "mysql" in a default Debian install (I assume it should be the same for Ubuntu); to verify this, check /etc/mysql/my.cnf and look for a "user = xxx" line.

Once you know what user mysqld is trying to run as, check that the directory /var/lib/mysql-files exists (sudo mkdir /var/lib/mysql-files if it doesn't) and is owned by the user mysqld runs as (sudo chown mysql /var/lib/mysql-files if it isn't; replace "mysql" in the chown command with the correct user name if you're configured to run as a different user).

Then try sudo mysqld again and you should either get a successful mysqld startup, or (if there are other problems with your setup) a new and different error message.


For me, I ran some cache clearing operations to free up space using tools like Stacer, and then MySQL started showing problems.

Use this to get some clues first

grep mysql /var/log/syslog | grep ERROR

If the error says, Could not open file '/var/log/mysql/error.log' for error logging: No such file or directory then clearly, the log files were cleaned up.

Use this to first create the MySQL directory and grant all permissions for MySQL to use that folder.

> sudo mkdir /var/log/mysql
> sudo chown -R mysql:mysql /var/log/mysql
> sudo service mysql restart

This solution has nothing to do with the my.cnf files and is completely safe on data.