0

I want active log file in mariadb for check last query used in php, i find mysql config in internet like as blow:

general_log_file        = /var/log/mysql/mysql.log
general_log             = 1

or

log = /var/log/mysql/mysql.log

I added this config in /etc/mysql/my.cnf and [mysql] section and restart mariadb service. but i didn't get any log, how to fix this?

i find answer:

[mysqld]
...
log_output = FILE
general_log = ON
general_log_file = mysql.log

mysql.log save in datadir, run SHOW VARIABLES WHERE variable_name = 'datadir' in mariadb to get datadir.

1
  • As this question shows up in search results here a reminder, you can use SET global general_log = 1 to activate logging 'on the fly' Whether or not you should do this depends on your circumstances of course...
    – nuala
    Commented Aug 9, 2022 at 12:33

1 Answer 1

1

You also need one of these:

log_output = FILE

log_output = TABLE

And put them in this section:

[mysqld]

('d' as in 'daemon' as in the 'server')

4
  • I added 3 lines: log_output = FILE general_log = ON general_log_file = /var/log/mysql/mysql.log but it still doesn't work.
    – Masoud92m
    Commented Dec 22, 2018 at 23:07
  • @Masoud92m - I added the other bug fix to my Answer.
    – Rick James
    Commented Dec 22, 2018 at 23:38
  • I updated my question, please check it.
    – Masoud92m
    Commented Dec 23, 2018 at 9:16
  • And you restarted the service?
    – Rick James
    Commented Dec 23, 2018 at 18:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.