折腾:
【未解决】Ubuntu中mysql有时候会突然挂掉
期间,此处Ubuntu中可以用service管理mysql:
service mysql status
其中能看到service文件:
Loaded: loaded (/lib/systemd/system/mysql.service; bad; vendor preset: enabled)
而为了解决mysql偶尔挂掉,需要搞清楚log日志文件在哪。好去找挂掉原因。
root@VM-158-80-ubuntu:~/xxx# cat /lib/systemd/system/mysql.service # MySQL systemd service file [Unit] Description=MySQL Community Server After=network.target [Install] WantedBy=multi-user.target [Service] User=mysql Group=mysql PermissionsStartOnly=true ExecStartPre=/usr/share/mysql/mysql-systemd-start pre ExecStart=/usr/sbin/mysqld ExecStartPost=/usr/share/mysql/mysql-systemd-start post TimeoutSec=600 Restart=on-failure RuntimeDirectory=mysqld RuntimeDirectoryMode=755
没找到log文件目录
ubuntu mysql log location
去
/var/log中看看
root@VM-158-80-ubuntu:~# ll /var/lo local/ lock/ log/ root@VM-158-80-ubuntu:~# ll /var/log/mysql mysql/ mysql.err mysql.log mysql.log.1 mysql.log.8.gz root@VM-158-80-ubuntu:~# ll /var/log/mysql* -rw-r----- 1 mysql adm 0 Feb 6 2017 /var/log/mysql.err -rw-r----- 1 mysql adm 0 Jun 7 06:25 /var/log/mysql.log -rw-r----- 1 mysql adm 0 Jun 6 06:25 /var/log/mysql.log.1 -rw-r----- 1 mysql adm 20 Aug 20 2018 /var/log/mysql.log.8.gz /var/log/mysql: total 36 drwxr-s--- 2 mysql adm 4096 Jun 7 21:23 ./ drwxrwxr-x 13 root syslog 4096 Jun 7 06:25 ../ -rw-r----- 1 mysql adm 12476 Jun 7 13:39 mariadb-bin.000392 -rw-r----- 1 mysql adm 154 Jun 7 21:23 mariadb-bin.000393 -rw-r----- 1 mysql adm 68 Jun 7 21:23 mariadb-bin.index -rw-rw---- 1 mysql adm 11 Aug 20 2018 mariadb-bin.state
很明显
root@VM-158-80-ubuntu:/var/log# ll mysql* -rw-r----- 1 mysql adm 0 Feb 6 2017 mysql.err -rw-r----- 1 mysql adm 0 Jun 7 06:25 mysql.log -rw-r----- 1 mysql adm 0 Jun 6 06:25 mysql.log.1 -rw-r----- 1 mysql adm 20 Aug 20 2018 mysql.log.8.gz
都是空的,无效的log。
真正有效的是,至少看起来有内容的是:
/var/log/mysql
中的:
mariadb-bin.000392
mariadb-bin.000393
mariadb-bin.index
mariadb-bin.state
【总结】
此处,是从,相对比较通用的路径:
/var/log/mysql
找到mysql的log文件的。
不过不是熟悉的.log,而是bin文件。
所以后续去:
【已解决】如何查看mysql或mariadb的bin二进制的log文件内容
【后记】
后来从mysql的配置文件:
/etc/mysql/my.cnf
root@VM-158-80-ubuntu:/var/log/mysql# cd /etc/mysql/ root@VM-158-80-ubuntu:/etc/mysql# ll total 36 drwxr-xr-x 4 root root 4096 Aug 20 2018 ./ drwxr-xr-x 112 root root 4096 Jan 9 09:54 ../ drwxr-xr-x 2 root root 4096 Aug 20 2018 conf.d/ -rw------- 1 root root 333 Feb 6 2017 debian.cnf -rwxr-xr-x 1 root root 120 Jul 28 2018 debian-start* -rw-r--r-- 1 root root 5231 Aug 20 2018 my.cnf -rw-r--r-- 1 root root 682 Feb 4 2017 mysql.cnf drwxr-xr-x 2 root root 4096 Aug 20 2018 mysql.conf.d/ root@VM-158-80-ubuntu:/etc/mysql# cat my.cnf ... socket = /var/run/mysqld/mysqld.sock ... socket = /var/run/mysqld/mysqld.sock ... [mysqld] # # * Basic Settings # user = mysql pid-file = /var/run/mysqld/mysqld.pid socket = /var/run/mysqld/mysqld.sock port = 3306 basedir = /usr datadir = /var/lib/mysql tmpdir = /tmp lc_messages_dir = /usr/share/mysql ... slow_query_log_file = /var/log/mysql/mariadb-slow.log ... log_bin = /var/log/mysql/mariadb-bin log_bin_index = /var/log/mysql/mariadb-bin.index
中看到了,的确是bin的log,路径就是前面我们看到的:
/var/log/mysql/mariadb-bin
/var/log/mysql/mariadb-bin.index
转载请注明:在路上 » 【已解决】Ubuntu中mysql的log日志文件在哪