5

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.

dongpt
  • 51
  • 1
  • 1
  • 4
  • In your config file (my.cnf) do you not have error-log and syslog uncommented? – Dane Balia Jun 18 '14 at 11:17
  • Do you have apparmor or selinux enabled? Those can block access to log files if you put them in non-default locations. And the error is often a red herring like that, complaining it can't find the file when it's obviously there. – Bill Karwin Jun 18 '14 at 15:22
  • @BillKarwin: plz check my update above. I have a question: the content I append to the mysqld file is about the log path or about the data path? – dongpt Jun 18 '14 at 15:53
  • mysqld shut itself down. See "mysqld...ended" on the last line. Also, the general log is for queries. If you didn't run any queries (and you can't while mysqld is shut down), the general log will be empty. – Bill Karwin Jun 18 '14 at 15:59
  • Did you [reload the apparmor profile](https://help.ubuntu.com/community/AppArmor)? In any case, I'd suggest a test to shut off apparmor and then try starting mysqld. – Bill Karwin Jun 18 '14 at 16:02
  • @BillKarwin: thanks for your hint! I solved my issue and updated in my post. I think the most important point that is I didn't reload the apparmor after changing mysqld profile. – dongpt Jun 19 '14 at 10:08

1 Answers1

5

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

Samrendra
  • 117
  • 1
  • 2