{"id":4742,"date":"2020-04-13T11:36:10","date_gmt":"2020-04-13T04:36:10","guid":{"rendered":"https:\/\/tino.vn\/?post_type=ht_kb&#038;p=4742"},"modified":"2020-04-13T11:36:10","modified_gmt":"2020-04-13T04:36:10","slug":"xu-ly-loi-mysql-server-has-gone-away-tren-wordpress","status":"publish","type":"ht_kb","link":"https:\/\/tino.vn\/blog\/docs\/xu-ly-loi-mysql-server-has-gone-away-tren-wordpress\/","title":{"rendered":"X\u1eed l\u00fd l\u1ed7i \u201cMySQL Server Has Gone Away\u201d tr\u00ean WordPress"},"content":{"rendered":"<p>C\u01a1 s\u1edf d\u1eef li\u1ec7u l\u00e0 th\u00e0nh ph\u1ea7n ch\u00ednh c\u1ee7a h\u1ea7u h\u1ebft c\u00e1c trang web hi\u1ec7n \u0111\u1ea1i, do \u0111\u00f3 c\u00e1c l\u1ed7i li\u00ean quan \u0111\u1ebfn d\u1eef li\u1ec7u r\u1ea5t nh\u1ea1y c\u1ea3m. V\u00ed d\u1ee5 \u201cMySQL server has gone away\u201d c\u00f3 th\u1ec3 khi\u1ebfn b\u1ea1n tin r\u1eb1ng c\u01a1 s\u1edf d\u1eef li\u1ec7u c\u1ee7a b\u1ea1n \u0111\u00e3 b\u1ecb m\u1ea5t. \u0110i\u1ec1u \u0111\u00f3 c\u00f3 ngh\u0129a l\u00e0 b\u1ea1n c\u00f3 th\u1ec3 ph\u1ea3i d\u00f9ng \u0111\u1ebfn b\u1ea3n sao l\u01b0u m\u1edbi nh\u1ea5t c\u1ee7a m\u00ecnh \u0111\u1ec3 kh\u1edfi \u0111\u1ed9ng trang web c\u1ee7a b\u1ea1n.<\/p>\n<p>M\u1eb7c d\u00f9 nghe c\u00f3 v\u1ebb \u0111\u00e1ng s\u1ee3, tuy nhi\u00ean l\u1ed7i \u201cMySQL server has gone away\u201d r\u1ea5t d\u1ec5 kh\u1eafc ph\u1ee5c. Ch\u1ec9 c\u1ea7n b\u1ea1n ki\u1ec3m tra theo c\u00e1c h\u01b0\u1edbng d\u1eabn d\u01b0\u1edbi \u0111\u00e2y, website c\u1ee7a b\u1ea1n c\u00f3 th\u1ec3 online l\u1ea1i trong v\u00e0i ph\u00fat.<\/p>\n<p>Trong b\u00e0i vi\u1ebft n\u00e0y, ch\u00fang t\u00f4i s\u1ebd gi\u1edbi thi\u1ec7u cho b\u1ea1n bi\u1ebft l\u1ed7i \u201cMySQL server has gone away\u201d nh\u01b0 th\u1ebf n\u00e0o v\u00e0 c\u00f3 th\u1ec3 g\u00e2y ra l\u1ed7i g\u00ec cho website. Sau \u0111\u00f3, ch\u00fang t\u00f4i s\u1ebd h\u01b0\u1edbng d\u1eabn b\u1ea1n c\u00e1ch kh\u1eafc ph\u1ee5c v\u00e0 ng\u0103n l\u1ed7i n\u00e0y xu\u1ea5t hi\u1ec7n l\u1ea1i trong t\u01b0\u01a1ng lai.<\/p>\n<p><span style=\"font-size: 18pt;\">Nguy\u00ean nh\u00e2n c\u1ee7a l\u1ed7i \u201cMySQL server has gone away\u201d<\/span><\/p>\n<ul>\n<li>Database b\u1ecb corrupted, l\u1ed7i table\u00a0 ho\u1eb7c kh\u00f4ng th\u1ec3 \u0111\u1ecdc \u0111\u01b0\u1ee3c d\u1eef li\u1ec7u<\/li>\n<li>PHP \u2018timeout\u2019 \u0111\u01b0\u1ee3c thi\u1ebft l\u1eadp qu\u00e1 th\u1ea5p<\/li>\n<li>\u2018Packets\u2019 d\u1eef li\u1ec7u tr\u1ea3 v\u1ec1 qu\u00e1 l\u1edbn<\/li>\n<\/ul>\n<p><span style=\"font-size: 18pt;\">C\u00e1ch x\u1eed l\u00fd l\u1ed7i \u201cMySQL Server Has Gone Away\u201d<\/span><\/p>\n<p>1. Ch\u1ec9nh s\u1eeda wp-db.php<\/p>\n<p>Tr\u01b0\u1eddng h\u1ee3p PHP timeout c\u1ea5u h\u00ecnh qu\u00e1 th\u1ea5p m\u00e0 database l\u1ea1i qu\u00e1 l\u1edbn d\u1eabn \u0111\u1ebfn t\u00ecnh tr\u1ea1ng khi h\u1ebft th\u1eddi gian PHP timeout nh\u01b0ng database v\u1eabn ch\u01b0a query ho\u00e0n t\u1ea5t c\u00f3 th\u1ec3 d\u1eabn \u0111\u1ebfn l\u00f4i \u201cMySQL Server Has Gone Away\u201d. B\u1ea1n c\u00f3 th\u1ec3 c\u1ea5u h\u00ecnh PHP timeout trong file wp-db.php\u00a0 nh\u01b0 sau: Truy c\u1eadp th\u01b0 m\u1ee5c <em>wp-includes &gt;\u00a0<\/em>m\u1edf file wp-db.php\u00a0 thay \u0111\u1ed5i \u0111\u1ecdn code sau<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">$this-&gt;ready = true;<\/pre>\n<p>thay th\u1ebf b\u1eb1ng codde d\u01b0\u1edbi \u0111\u00e2y<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">$this-&gt;query(\"set session wait_timeout=300\");<\/pre>\n<p>Thay \u0111\u1ed5i n\u00e0y s\u1ebd \u0111\u1eb7t gi\u00e1 tr\u1ecb th\u1eddi gian ch\u1edd PHP c\u1ee7a b\u1ea1n th\u00e0nh 300 gi\u00e2y, s\u1ebd cao h\u01a1n r\u1ea5t nhi\u1ec1u so v\u1edbi m\u1ee9c b\u1ea1n c\u1ea7n \u0111\u1ec3 ng\u0103n ch\u1eb7n b\u1ea5t k\u1ef3 l\u1ed7i n\u00e0o hi\u1ec3n th\u1ecb.<\/p>\n<p>B\u00e2y gi\u1edd h\u00e3y l\u01b0u c\u00e1c thay \u0111\u1ed5i v\u00e0o t\u1ec7p wp-db.php c\u1ee7a b\u1ea1n v\u00e0\u00a0 ki\u1ec3m tra ho\u1ea1t \u0111\u1ed9ng.<\/p>\n<p>2. Repair database website<\/p>\n<p>\u0110\u00f4i khi c\u01a1 s\u1edf d\u1eef li\u1ec7u WordPress c\u1ee7a b\u1ea1n c\u00f3 th\u1ec3 b\u1ecb h\u1ecfng, do \u0111\u00f3 c\u00f3 th\u1ec3 d\u1eabn \u0111\u1ebfn l\u1ed7i khi b\u1ea1n c\u1ed1 g\u1eafng thi\u1ebft l\u1eadp k\u1ebft n\u1ed1i v\u1edbi n\u00f3.<\/p>\n<p>\u0110\u1ec3 kh\u1eafc ph\u1ee5c s\u1ef1 c\u1ed1 n\u00e0y, b\u1ea1n c\u00f3 th\u1ec3 s\u1eed d\u1ee5ng ch\u1ee9c n\u0103ng WordPress t\u00edch h\u1ee3p \u0111\u1ec3 s\u1eeda ch\u1eefa c\u01a1 s\u1edf d\u1eef li\u1ec7u c\u1ee7a m\u00ecnh. Tuy nhi\u00ean, tr\u01b0\u1edbc ti\u00ean, b\u1ea1n s\u1ebd ph\u1ea3i k\u00edch ho\u1ea1t t\u00ednh n\u0103ng \u0111\u00f3. \u0110i\u1ec1u n\u00e0y c\u1ea7n b\u1ea1n\u00a0 m\u1edf t\u1ec7p wp-config.php \u0111\u1ec3 ch\u1ec9nh s\u1eeda n\u00f3 v\u00e0 th\u00eam v\u00e0o \u0111o\u1ea1n\u00a0 code sau<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">define('WP_ALLOW_REPAIR', true);<\/pre>\n<div class=\"ddict_div\">\n<p class=\"ddict_sentence\">D\u00f2ng m\u00e3 \u0111\u01a1n gi\u1ea3n \u0111\u00f3 b\u1ea3o WordPress k\u00edch ho\u1ea1t ch\u1ee9c n\u0103ng s\u1eeda ch\u1eefa c\u01a1 s\u1edf d\u1eef li\u1ec7u. L\u01b0u c\u00e1c thay \u0111\u1ed5i v\u00e0o wp-config.php . \u0110\u1ec3 ch\u1ea1y ch\u1ee9c n\u0103ng, ch\u1ec9 c\u1ea7n truy c\u1eadp URL sau:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">https:\/\/yourwebsite.com\/wp-admin\/maint\/repair.php<\/pre>\n<div class=\"ddict_div\">\n<p class=\"ddict_sentence\">WordPress sau \u0111\u00f3 s\u1ebd h\u1ecfi b\u1ea1n c\u00f3 mu\u1ed1n s\u1eeda ch\u1eefa c\u01a1 s\u1edf d\u1eef li\u1ec7u c\u1ee7a b\u1ea1n ho\u1eb7c s\u1eeda ch\u1eefa v\u00e0 t\u1ed1i \u01b0u h\u00f3a n\u00f3 kh\u00f4ng.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2020\/04\/repair-database-wordpress-option1.png\" alt=\"\" title=\"\"><\/p>\n<p>Sau khi repair\u00a0 ho\u00e0n t\u1ea5t b\u1ea1n c\u00f3 th\u1ec3 g\u1ee1 b\u1ecf do\u1ea1n code v\u1eeba th\u00eam \u1edf tr\u00ean v\u00e0 ki\u1ec3m tra truy c\u1eadp.<\/p>\n<\/div>\n<\/div>\n<p>3.\u00a0 Restore d\u1eef li\u1ec7u c\u1ee7a b\u1ea1n v\u1ec1 th\u1eddi \u0111i\u1ec3m tr\u01b0\u1edbc khi c\u00f3 l\u1ed7i s\u1ea3y ra n\u1ebfu nh\u01b0 thaot \u00e1c repair database kh\u00f4ng kh\u1eafc ph\u1ee5c \u0111\u01b0\u1ee3c l\u1ed7i<\/p>\n<p>Ph\u01b0\u01a1ng \u00e1n n\u00e0y l\u00e0 ph\u01b0\u01a1ng \u00e1n cu\u1ed1i c\u00f9ng, \u0111\u1ed1i v\u1edbi hosting t\u1ea1i TinoHost b\u1ea1n c\u00f3 th\u1ec3 l\u00e0m theo h\u01b0\u1edbng d\u1eabn sau \u0111\u1ec3 restore d\u1eef li\u1ec7u.<\/p>\n<p>\u0110\u1ed1i v\u1edbi vps b\u1ea1n s\u1ebd c\u1ea7n th\u1eed hi\u1ec7n th\u1eed c\u00f4ng restore t\u1eeb c\u00e1c b\u1ea3n backup \u0111\u1ecbnh k\u1ef3 l\u00e0 b\u1ea1n \u0111\u00e3\u00a0 thi\u1ebft l\u1eadp tr\u01b0\u1edbc \u0111\u00f3.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>C\u01a1 s\u1edf d\u1eef li\u1ec7u l\u00e0 th\u00e0nh ph\u1ea7n ch\u00ednh c\u1ee7a h\u1ea7u h\u1ebft c\u00e1c trang web hi\u1ec7n \u0111\u1ea1i, do \u0111\u00f3 c\u00e1c l\u1ed7i li\u00ean quan \u0111\u1ebfn d\u1eef li\u1ec7u r\u1ea5t nh\u1ea1y c\u1ea3m. V\u00ed d\u1ee5 \u201cMySQL server has gone away\u201d c\u00f3 th\u1ec3 khi\u1ebfn b\u1ea1n tin r\u1eb1ng c\u01a1 s\u1edf d\u1eef li\u1ec7u c\u1ee7a b\u1ea1n \u0111\u00e3 b\u1ecb m\u1ea5t. \u0110i\u1ec1u \u0111\u00f3 c\u00f3 ngh\u0129a l\u00e0 [&hellip;]<\/p>\n","protected":false},"author":11,"featured_media":16424,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","format":"standard","meta":{"footnotes":""},"tags":[],"ht_kb_category":[5167],"class_list":["post-4742","ht_kb","type-ht_kb","status-publish","format-standard","has-post-thumbnail","hentry","ht_kb_category-cau-hoi-chung-ve-wordpress"],"_links":{"self":[{"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/ht_kb\/4742","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/ht_kb"}],"about":[{"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/types\/ht_kb"}],"author":[{"embeddable":true,"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/users\/11"}],"replies":[{"embeddable":true,"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/comments?post=4742"}],"version-history":[{"count":0,"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/ht_kb\/4742\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/media\/16424"}],"wp:attachment":[{"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/media?parent=4742"}],"wp:term":[{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/tags?post=4742"},{"taxonomy":"ht_kb_category","embeddable":true,"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/ht_kb_category?post=4742"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}