Where are logs of MySQL ? Fedora

20,534

Solution 1

If you have mysqld running you can inspect its open descriptors to see where it logs, for example using proc:

[root@localhost ~]# ls -l `pgrep mysqld | sed 's@.*@/proc/&/fd/@'` | grep log
l-wx------. 1 root root 64 Jul 23 10:47 1 -> /var/log/mysqld.log
l-wx------. 1 root root 64 Jul 23 10:47 2 -> /var/log/mysqld.log
lrwx------. 1 root root 64 Jul 23 10:47 8 -> /var/lib/mysql/ib_logfile0
lrwx------. 1 root root 64 Jul 23 10:47 9 -> /var/lib/mysql/ib_logfile1
[root@localhost ~]# 

In this case is /var/log/mysqld.log

Solution 2

There are different types of logs which are determined by the following global MySQL variables:

If you would like to read the error log file, try this command:

sudo tail -f $(mysql -Nse "SELECT @@GLOBAL.log_error")

then hit Control-C when finish.

Share:
20,534

Related videos on Youtube

CSharpBeginner
Author by

CSharpBeginner

Updated on September 18, 2022

Comments

  • CSharpBeginner
    CSharpBeginner over 1 year

    Hello I just installed MySQL on my Fedora from Source, with cmake,make,make install etc. It's working, but where can I find logs of the server? I have looked into /var/log, but there is nothing with mysql unfortunately.

    /etc/my.cnf

    # For advice on how to change settings please see
    # 
    # *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
    # *** default location during install, and will be replaced if you
    # *** upgrade to a newer version of MySQL.
    
    [mysqld]
    # Remove leading # and set to the amount of RAM for the most important data
    # cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
    # innodb_buffer_pool_size = 128M
    
    # Remove leading # to turn on a very important data integrity option: logging
    # changes to the binary log between backups.
    # log_bin
    
    # These are commonly set, remove the # and set as required.
    # basedir = .....
    # datadir = .....
    # port = .....
    # server_id = .....
    # socket = .....
    
    # Remove leading # to set options mainly useful for reporting servers.
    # The server defaults are faster for transactions and fast SELECTs.
    # Adjust sizes as needed, experiment to find the optimal values.
    # join_buffer_size = 128M
    # sort_buffer_size = 2M
    # read_rnd_buffer_size = 2M 
    
    sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES    
    
    • pabouk - Ukraine stay strong
      pabouk - Ukraine stay strong over 10 years
      Could you please specify version of MySQL and Fedora and if you configured some compilation parameters of MySQL?
  • CSharpBeginner
    CSharpBeginner over 10 years
    When I did this it only list the ib_logfile0 and ib_logfile1, when i try to cat them, they are full of @@@@@@@@@@@@@ :/
  • cyberz
    cyberz over 10 years
    Looks like your mysql is not logging at all, then. The logfile0..1 are binary logfiles of db data, not human readable logfiles.
  • cyberz
    cyberz over 10 years
    Check your my.cnf, for example on mine I have: log-error=/var/log/mysqld.log under the [mysqld_safe] section.
  • CSharpBeginner
    CSharpBeginner over 10 years
    My my.cnf if almost empty, my mysql is running, I logged, create databases, tables, 2 users, logged with them, everything looked fine, i paste my "etc/my.cnf" in edit #1
  • cyberz
    cyberz over 10 years
    Add log-error=/var/log/mysqld.log in the [mysqld_safe] and restart MySQL server, it should log. Also ensure that the /var/log/mysqld.log is writable by the mysql user.
  • CSharpBeginner
    CSharpBeginner over 10 years
    Its working, but its not writing information about who log/ who tried to log but fail. What should i write in my.cnf to get such a info ? :)
  • cyberz
    cyberz over 10 years
    This is another question. Try enabling general log as shown in mysqlperformanceblog.com/2012/12/28/…
  • CSharpBeginner
    CSharpBeginner over 10 years
    but it onlt shows how many people is logged, is it possible to get login for example : User Tom has Logged, User Jane wrote wrong password fail logging ?