{"id":11263,"date":"2023-02-02T10:47:02","date_gmt":"2023-02-02T02:47:02","guid":{"rendered":"https:\/\/blog.ywdevops.cn\/?p=11263"},"modified":"2025-09-29T10:15:30","modified_gmt":"2025-09-29T02:15:30","slug":"mysql-10","status":"publish","type":"post","link":"https:\/\/blog.ywdevops.cn\/index.php\/2023\/02\/02\/mysql-10\/","title":{"rendered":"MySQL\u5e38\u89c1\u95ee\u9898"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">1\u3001<strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-purple-color\">\u4eceMySQL8\u5bfc\u51fasql\u540e\u5bfc\u5165\u5230MySQL5.7\u7248\u672c\u4e2d\u9700\u8981\u89e3\u51b3\u7684\u95ee\u9898<\/mark><\/strong>\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u66ff\u6362\u5b57\u7b26\u96c6\uff1autf8mb4_0900_ai_ci -&gt; utf8_general_ci<\/li>\n\n\n\n<li>\u7f16\u7801\u8f6c\u6362\uff1a    utf8mb4 -&gt; utf8<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">2\u3001<strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-purple-color\">mysql\u4ece\u5e93\u540c\u6b65\u8fc7\u7a0b\u4e2d\u62a5\u9519\u5982\u4e0b<\/mark><\/strong>\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"645\" height=\"119\" src=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2025\/02\/wechat_2025-02-28_115521_210.png\" alt=\"\" class=\"wp-image-17920\" srcset=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2025\/02\/wechat_2025-02-28_115521_210.png 645w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2025\/02\/wechat_2025-02-28_115521_210-300x55.png 300w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2025\/02\/wechat_2025-02-28_115521_210-600x111.png 600w\" sizes=\"auto, (max-width: 645px) 100vw, 645px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u67e5\u770b\u9519\u8bef\u65e5\u5fd7\u5185\u5bb9\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Error 'Lock wait timeout exceeded; try restarting transaction' on query. Default database: 'spt'. Query: 'delete from sync_change  where create_time &lt; DATE_SUB(NOW(),INTERVAL 90 DAY)', Error_code: 1205<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"656\" height=\"127\" src=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2025\/02\/wechat_2025-02-28_115336_296.png\" alt=\"\" class=\"wp-image-17922\" srcset=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2025\/02\/wechat_2025-02-28_115336_296.png 656w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2025\/02\/wechat_2025-02-28_115336_296-300x58.png 300w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2025\/02\/wechat_2025-02-28_115336_296-600x116.png 600w\" sizes=\"auto, (max-width: 656px) 100vw, 656px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u4ece\u9519\u8bef\u53ef\u4ee5\u770b\u51fa\uff0c\u662f\u8868sync_change\u4ea7\u751f\u4e86\u9501\uff0c\u963b\u585e\u4e86delete\u8bed\u53e5\u7684\u6267\u884c\uff0c\u91cd\u8bd5\u4e8610\u6b21\u540e\u8fd8\u662f\u4e0d\u884c\uff0c\u56e0\u6b64\u5bfc\u81f4\u590d\u5236\u4e2d\u65ad\uff0c\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u53c2\u6570innodb_lock_wait_time\u7684\u65f6\u95f4\u4e3a50s\uff0c\u56e0\u6b64\uff0c\u89e3\u51b3\u9501\u7b49\u5f85\u8d85\u65f6\u7684\u529e\u6cd5\u5c31\u53ef\u4ee5\u589e\u52a0\u8fd9\u4e2a\u53c2\u6570\u7684\u503c\uff0c\u5e76\u589e\u52a0\u91cd\u8bd5\u7684\u6b21\u6570\uff0c\u5728my.cnf\u4e2d\uff0c\u6dfb\u52a0\u53c2\u6570\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>innodb_lock_wait_time 300      #\u53ef\u6839\u636e\u81ea\u5df1\u9700\u8981\u589e\u52a0\nslave_transaction_retries 100  #\u91cd\u8bd5100\u6b21\ninnodb_thread_concurrency = 10 #\u9ad8\u5e76\u53d1\u7ebf\u7a0b\u6570\uff0c\u4e00\u822c\u4e3acpu\u00d72<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">3\u3001<strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-purple-color\">mysql\u4ece\u5e93\u62a5\u9519<\/mark><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Last_SQL_Errno: 1062\nLast_SQL_Error: Error 'Duplicate entry '3116971' for key 'PRIMARY'' on query. Default database: 'xxl_job'. Query: 'INSERT INTO XXL_JOB_QRTZ_TRIGGER_LOG (<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u9519\u8bef\u8868\u660e\u4ece\u5e93\u5728\u5c1d\u8bd5\u63d2\u5165\u4e00\u6761\u4e3b\u952e\u51b2\u7a81\u7684\u6570\u636e\u3002\u8fd9\u662f\u56e0\u4e3a\u4ece\u5e93\u5df2\u7ecf\u5b58\u5728\u4e3b\u952e\u4e3a&nbsp;<code>3116971<\/code>&nbsp;\u7684\u8bb0\u5f55\uff0c\u800c\u4e3b\u5e93\u53c8\u5c1d\u8bd5\u63d2\u5165\u76f8\u540c\u4e3b\u952e\u7684\u6570\u636e\uff0c\u5bfc\u81f4\u590d\u5236\u4e2d\u65ad<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u89e3\u51b3\u529e\u6cd5\uff0c\u5220\u9664\u4ece\u5e93\u4e2d\u51b2\u7a81\u7684\u8bb0\u5f55\uff08\u591a\u6761\u8bb0\u5f55\u5c31\u90fd\u5220\u9664\uff09\uff0c\u6267\u884c\u547d\u4ee4\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>DELETE FROM erp_xxl_job.XXL_JOB_QRTZ_TRIGGER_LOG WHERE id = 3116971;\nstop slave;\nstart slave;<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-purple-color\">4\u3001mysql\u4e3b\u4ece\u72b6\u6001\u6b63\u5e38\uff0c\u4f46\u662f\u5728\u4e3b\u6267\u884c\u4e86\u547d\u4ee4\u540e\uff0c\u4ece\u5e93\u6ca1\u6709\u540c\u6b65\u66f4\u65b0<\/mark><\/strong>\uff0c\u67e5\u770b\u9519\u8bef\u5185\u5bb9\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;ERROR] InnoDB: innodb_force_recovery is on. We do not allow database modifications by the user. Shut down mysqld and edit my.cnf to set innodb_force_recovery=0<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd9\u4e2a\u9519\u8bef\u8868\u660e MySQL \u7684&nbsp;<code>innodb_force_recovery<\/code>&nbsp;\u53c2\u6570\u88ab\u8bbe\u7f6e\u4e3a\u975e\u96f6\u503c\uff08\u901a\u5e38\u7528\u4e8e\u4fee\u590d InnoDB \u8868\u635f\u574f\u95ee\u9898\uff09\uff0c\u5bfc\u81f4 MySQL \u5904\u4e8e\u53ea\u8bfb\u6a21\u5f0f\uff0c\u7981\u6b62\u7528\u6237\u4fee\u6539\u6570\u636e<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>innodb_force_recovery<\/code>&nbsp;\u662f\u4e00\u4e2a InnoDB \u5f15\u64ce\u7684\u6545\u969c\u6062\u590d\u53c2\u6570\uff0c\u7528\u4e8e\u5728\u6570\u636e\u5e93\u5d29\u6e83\u6216\u8868\u635f\u574f\u65f6\u5c1d\u8bd5\u6062\u590d\u6570\u636e\u3002\u5b83\u7684\u53d6\u503c\u8303\u56f4\u662f&nbsp;<code>0<\/code>&nbsp;\u5230&nbsp;<code>6<\/code>\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>0\uff1a\u6b63\u5e38\u6a21\u5f0f\uff08\u9ed8\u8ba4\u503c\uff09<\/li>\n\n\n\n<li>1-6\uff1a\u5f3a\u5236\u6062\u590d\u6a21\u5f0f\uff0c\u7ea7\u522b\u8d8a\u9ad8\uff0c\u6062\u590d\u64cd\u4f5c\u8d8a\u6fc0\u8fdb\uff0c\u4f46\u6570\u636e\u5e93\u4f1a\u53d8\u4e3a\u53ea\u8bfb\u6a21\u5f0f<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">\u89e3\u51b3\u529e\u6cd5\uff1a\u4fee\u6539\/etc\/my.cnf\uff0c\u5c06innodb_force_recovery\u4fee\u6539\u4e3a0\u540e\u91cd\u542f\u5373\u53ef<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-purple-color\">5\u3001mysql\u901a\u8fc7root\u7528\u6237\u6267\u884cgrant\u547d\u4ee4\u7684\u65f6\u5019\u62a5\u9519\u5982\u4e0b<\/mark><\/strong>\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Access denied for user 'root'@'%' to database 'dbname'\"<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u6267\u884c\u547d\u4ee4\u67e5\u770bmysql\u7684\u6743\u9650\u60c5\u51b5\uff0c\u5982\u56fe\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>select * from mysql.user where user = \"root\";<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"655\" height=\"424\" src=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2025\/04\/wechat_2025-04-16_172846_563.png\" alt=\"\" class=\"wp-image-18032\" srcset=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2025\/04\/wechat_2025-04-16_172846_563.png 655w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2025\/04\/wechat_2025-04-16_172846_563-300x194.png 300w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2025\/04\/wechat_2025-04-16_172846_563-600x388.png 600w\" sizes=\"auto, (max-width: 655px) 100vw, 655px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u4ece\u4e0a\u56fe\u5361\u770b\u51fa,Grant_priv\u4e3aN\uff0c\u4e5f\u5c31\u8bf4\u662f\u6ca1\u6709grant\u6743\u9650\u7684\uff0c\u6b64\u65f6\u9700\u8981\u4fee\u6539\u4e3aY\u5c31\u53ef\u4ee5\u5566\uff0c\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>update mysql.user set Grant_priv = \"Y\" where user = \"root\";<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">6\u3001MySQL\u542f\u52a8\u6216\u8005\u8fde\u63a5\u62a5\u9519\uff0c\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mysql: &#91;Warning] World-writable config file '\/etc\/mysql\/mysql.conf.d\/mysqld.cnf' is ignored <\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u6b64\u9519\u8bef\u8bf4\u660eMySQL\u7684\u914d\u7f6e\u6587\u4ef6\u6743\u9650\u7ed9\u7684\u8fc7\u4e8e\u5bbd\u677e(\u53ef\u80fd\u662f\u7ed9\u4e86777)\uff0c\u5bfc\u81f4mysql\u62d2\u7edd\u8fde\u63a5\uff0c\u4fee\u6539\u4e3a644\u5373\u53ef<\/p>\n","protected":false},"excerpt":{"rendered":"<p>1\u3001\u4eceMySQL8\u5bfc\u51fasql\u540e\u5bfc\u5165\u5230MySQL5.7\u7248\u672c\u4e2d\u9700\u8981\u89e3\u51b3\u7684\u95ee\u9898\uff1a 2\u3001mysql\u4ece\u5e93\u540c\u6b65\u8fc7\u7a0b\u4e2d\u62a5\u9519\u5982 [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":11265,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[35,25],"tags":[],"class_list":["post-11263","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-mysql","category-database"],"blocksy_meta":{"styles_descriptor":{"styles":{"desktop":"","tablet":"","mobile":""},"google_fonts":[],"version":8}},"_links":{"self":[{"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/posts\/11263","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/comments?post=11263"}],"version-history":[{"count":10,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/posts\/11263\/revisions"}],"predecessor-version":[{"id":19123,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/posts\/11263\/revisions\/19123"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/media\/11265"}],"wp:attachment":[{"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/media?parent=11263"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/categories?post=11263"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/tags?post=11263"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}