MySQL error log file location on Ubuntu/Debian Server – MySQL Log Location

MySQL error log file location on Ubuntu/Debian Server – MySQL Log Location

 

mySQL logs on Ubuntu/Debian Server is saved in /var/log directory. Log into your Ubuntu/Debian Server via SSH

Change directory to /var/log
 

root@server [/]# cd /var/log/

 
Type “ls -l” to see all log files in /var/log directory
 

root@server [/var/log/]# ls -l

 
mySQL log file on Ubuntu/Debian is /var/log/mysql.err.

You can use tail command to view the last ‘n’ lines of mySQL error log file. MySQL error log file on ubuntu/debian server is /var/log/mysql.log
 

root@server [/var/log/]# tail -n 30 mysql.err

 
MySQL log file is /var/log/mysql.log
 

root@server [/var/log/]# tail -n 30 mysql.log

 
If there is no log file in /var/log then you might have set a different log file location in your mySQL configuration my.cnf file. Check my.cnf for exact location of mySQL log file.

If there is no log file location specified in the my.cnf then try the below command to locate the log file location of mySQL.

Command : mysqladmin variables | grep -i log

The above command will display mySQL log file location.

OR

You can also check Check the lsof mySQL process ID to find the mySQL log file location
 

root@server [/]# pgrep mysql
23456

 
“pgrep mysql” will show the process ID of mySQL. lsof -p “PID” will list all open files of that process
 

root@server [/]# lsof -p 23456 | grep log

mysqld 23456 mysql 177r REG 0,49 0 12196363 /var/lib/mysql/mysql.err