我的数据库是 8GB
当我运行数据库备份 bash 脚本时,出现警告/失败。它们自 1 个月前出现以来
这是我的警告/失败
mysqldump: Error 2013: Lost connection to MySQL server during query when dumping table `xxx` at row: 427348
mysqldump: Couldn't execute 'SELECT engine, table_type FROM INFORMATION_SCHEMA.TABLES WHERE table_schema = DATABASE() AND table_name = 'xxx'': MySQL server has gone away (2006)
mysqldump: Couldn't execute 'SET SQL_QUOTE_SHOW_CREATE=1': MySQL server has gone away (2006)
.....
mysqldump: Couldn't execute 'UNLOCK TABLES': MySQL server has gone away (2006)
mysqldump: Got error: 2002: "Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111)" when trying to connect
答案1
和Error 2013: Lost connection to MySQL server
错误MySQL server has gone away (2006)
通常意味着程序与数据库之间的连接意外中断。通常,这种情况是由于连接被某些原因终止、服务器内存不足或由于错误导致服务器进程崩溃而发生的。
要找出实际原因,请检查服务器错误日志(默认情况下为)/var/lib/mysql/hostname.err
。
答案2
如果服务器由于某种原因没有重新启动,添加--quick --single-transaction
可能mysqldump
会有帮助。