MySQL Daemon failed to start
Mysql出问题一定要学会查看log
https://blog.csdn.net/shuai825644975/article/details/79473236
mysql突然挂了,重启提示:MySQL Daemon failed to start
用mysql -root -p登录,提示[mysql]ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
查了下日志(var/log/mysqld.log)
2018-03-07T08:02:15.926378Z 0 [ERROR] InnoDB: mmap(137428992 bytes) failed; errno 12
2018-03-07T08:02:15.926392Z 0 [ERROR] InnoDB: Cannot allocate memory for the buffer pool
2018-03-07T08:02:15.926401Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error
2018-03-07T08:02:15.926410Z 0 [ERROR] Plugin 'InnoDB' init function returned error.
2018-03-07T08:02:15.926415Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2018-03-07T08:02:15.926421Z 0 [ERROR] Failed to initialize plugins.
2018-03-07T08:02:15.926426Z 0 [ERROR] Aborting
从日志看,在分配内存的时候出错了
查看内存,swap是0
适当增加swap
1、给swap分配2G物理内存:dd if=/dev/zero of=/var/swap bs=1024 count=2048000
2、将文件变成swap分区:mkswap /var/swap
3、开启swap:swapon /var/swap
设置好后,再启动mysql,成功
参考:https://www.cnblogs.com/olinux/p/5144205.html
参考:http://www.k2zone.cn/?p=1182