I faced with this error after trying to restart MySQL server.
root@private:/# mysqld_safe
140618 03:56:53 mysqld_safe Can't log to error log and syslog at the same time. Remove all --log-error configuration options for --syslog to take effect.
140618 03:56:53 mysqld_safe Logging to '/var/log/mysql/error.log'.
140618 03:56:53 mysqld_safe Starting mysqld daemon with databases from /mysql
140618 03:56:53 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
The approach I've followed (and most found on internet) that is changing permission of /var/log/mysql to mysql user. But it doesn't work.
drwxr-s--- 2 mysql mysql 4096 Jun 18 03:31 mysql/
Inside:
root@private:/var/log# ll mysql
total 12
drwxr-s--- 2 mysql mysql 4096 Jun 18 03:31 ./
drwxr-xr-x 24 root root 4096 Jun 18 03:27 ../
-rw-r----- 1 mysql mysql 1989 Jun 18 03:34 error.log
-rwxrwxrwx 1 mysql mysql 0 Jun 18 03:13 mysql-bin.index*
My data path:
drwxr-xr-x 3 mysql mysql 4096 Jun 18 03:27 mysql/
I even tried to re-install MySQL as well but the error doesn't disappear.
Please help me!!!
Update 1: About my.cnf - error-log configuration. I turned on both general and error log (to error.log). But nothing inside the general log file. For the error log file, there is no thing more than the error I copied above.
# Both location gets rotated by the cronjob.
# Be aware that this log type is a performance killer.
# As of 5.1 you can enable the log at runtime!
general_log_file = /var/log/mysql/mysql.log
general_log = 1
#
# Error log - should be very few entries.
#
log_error = /var/log/mysql/error.log
#
# Here you can see queries with especially long duration
#log_slow_queries = /var/log/mysql/mysql-slow.log
#long_query_time = 2
#log-queries-not-using-indexes
Update 2: regarding the question of apparmor or selinux, I just use apparmor. I also tried to append:
/var/log/* rw
to
/etc/apparmor.d/usr.sbin.mysqld
but it either doesn't work
Update 3:
And I believe following changes did work for my case:
Have to be sure that mysql account has enough permission (rw) to your mysql log/data directories. From root or sudoer account just try to switch to mysql user then create/edit any test file.
Don't remove or disable apparmor and update mysql profile (normally usr.sbin.mysqld) with following thing:
/var/log/mysql-bin.index rw,
/mysql/* rw,
you might customize them according to your case.
reload mysql profile
apparmor_parser -r /etc/apparmor.d/usr.sbin.mysqld
and restart it.
Hope it will hep for any one who came across internet and paid hours for changing permission and apparmor without any lucky.
During replication configuration in "my.cnf" file needs to mention
server-id=1
log_bin=/var/log/mysql/mysql-bin.log
you can make your own directory and give permission. create directory "mysql" in /var/log/
chmod 777 mysql
this is applicable with MySQL version 5.7
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With