Whenever I change the log location
form: /var/log/mysql to: /var/www
in order to keep every log files in the same place (just under public folder) in mysqld.cnf mysql server cannot restart.
/etc/mysql/mysql.conf.d/mysqld.cnf
log_error = /var/log/mysql/mysql_errors.log
I checked for some solutions and added:
character-set-server = utf8
collation-server = utf8_general_ci
But still didn't work. /var/www has 770 permissions and belonging to www-data group.
I added mysql to www-data group:
sudo usermod -aG www-data mysql
But still didn't work.
MySQL: 5.7.19
Ubuntu: 16.04.1
Here is the error log:
Job for mysql.service failed because the control process exited with error code. See "systemctl status mysql.service" and "journalctl -xe" for details.
mysql.service: Main process exited, code=exited, status=1/FAILURE
Whenever I undo the log location change, it starts to work.
EDIT 31.07.2017
I run this after log location change:
sudo touch /var/www/mysql_errors.log
sudo chown mysql:mysql /var/www/mysql_errors.log
sudo chmod 770 /var/www/mysql_errors.log
sudo systemctl restart mysql
sudo journalctl -xe > ~/journal.txt
Here are the relevant log entities:
-- Unit mysql.service has begun starting up.
Jul 31 00:33:55 mydomain.com audit[1738]: AVC apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/proc/1738/status" pid=1738 comm="mysqld" requested_mask="r" denied_mask="r" fsuid=112 ouid=112
Jul 31 00:33:55 mydomain.com audit[1738]: AVC apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/var/www/mysql_errors.log" pid=1738 comm="mysqld" requested_mask="ac" denied_mask="ac" fsuid=112 ouid=112
Jul 31 00:33:55 mydomain.com audit[1738]: AVC apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld"
Jul 31 00:33:55 mydomain.com systemd[1]: mysql.service: Main process exited, code=exited, status=1/FAILURE
journalctl -xe