{"id":2152,"date":"2017-08-31T10:58:00","date_gmt":"2017-08-31T02:58:00","guid":{"rendered":"https:\/\/ai.zhousir.top\/?p=2152"},"modified":"2026-08-18T12:09:38","modified_gmt":"2026-08-18T04:09:38","slug":"2152","status":"publish","type":"post","link":"https:\/\/ai.zhousir.top\/?p=2152","title":{"rendered":"MySQL\u5b57\u7b26\u96c6\u8bbe\u7f6e"},"content":{"rendered":"<section id=\"wenyan\" style=\"font-family: system-ui, 'Apple Color Emoji', 'Segoe UI', 'Segoe UI Symbol', 'Noto Sans', Roboto, sans-serif; line-height: 1.75; font-size: 16px; color: #000000; caret-color: #000000;\" data-provider=\"WenYan\">\n<p style=\"margin: 1em 0px;\">MySQL \u5bf9\u5b57\u7b26\u96c6\u7684\u652f\u6301\u53ef\u4ee5\u7ec6\u5230\u56db\u4e2a\u5c42\u6b21\uff1a<strong style=\"color: #4870ac;\">\u670d\u52a1\u5668\uff08server\uff09<\/strong>\u3001<strong style=\"color: #4870ac;\">\u6570\u636e\u5e93\uff08database\uff09<\/strong>\u3001<strong style=\"color: #4870ac;\">\u6570\u636e\u8868\uff08table\uff09<\/strong>\u548c<strong style=\"color: #4870ac;\">\u8fde\u63a5\uff08connection\uff09<\/strong>\u3002\u6307\u5b9a\u65f6\u8fd8\u80fd\u843d\u5230\u4e00\u4e2a\u5e93\u3001\u4e00\u5f20\u8868\u3001\u4e00\u5217\u8be5\u7528\u4ec0\u4e48\u5b57\u7b26\u96c6\u3002<\/p>\n<p style=\"margin: 1em 0px;\">\u4f20\u7edf\u7a0b\u5e8f\u5efa\u5e93\u5efa\u8868\u5f80\u5f80\u4e0d\u914d\u8fd9\u4e48\u7ec6\uff0c\u7528\u7684\u662f\u9ed8\u8ba4\u503c\uff1b\u9ed8\u8ba4\u4e0d\u5bf9\uff0c\u67e5\u8be2\u548c\u5165\u5e93\u5c31\u4f1a\u4e71\u7801\u3002<\/p>\n<h2 style=\"padding: 1px 12.5px; color: #ffffff; margin: 1.2em 0px 1em; border-radius: 4px; display: inline-block; background-color: #4870ac; font-size: 1.3em;\">\u4e00\u3001\u76f8\u5173\u7cfb\u7edf\u53d8\u91cf<\/h2>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 12px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; overflow-x: auto; margin: 0.5em; padding: 3px 5px; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">\u2022 \u7cfb\u7edf\u53d8\u91cf\uff1a\n\u2013 character_set_server\uff1a\u9ed8\u8ba4\u7684\u5185\u90e8\u64cd\u4f5c\u5b57\u7b26\u96c6\n\u2013 character_set_client\uff1a\u5ba2\u6237\u7aef\u6765\u6e90\u6570\u636e\u4f7f\u7528\u7684\u5b57\u7b26\u96c6\n\u2013 character_set_connection\uff1a\u8fde\u63a5\u5c42\u5b57\u7b26\u96c6\n\u2013 character_set_results\uff1a\u67e5\u8be2\u7ed3\u679c\u5b57\u7b26\u96c6\n\u2013 character_set_database\uff1a\u5f53\u524d\u9009\u4e2d\u6570\u636e\u5e93\u7684\u9ed8\u8ba4\u5b57\u7b26\u96c6\n\u2013 character_set_system\uff1a\u7cfb\u7edf\u5143\u6570\u636e(\u5b57\u6bb5\u540d\u7b49)\u5b57\u7b26\u96c6<\/code><\/pre>\n<table style=\"display: table; text-align: left; overflow: auto; border-collapse: collapse; margin: 1.4em auto; max-width: 100%; table-layout: fixed; overflow-wrap: break-word; word-break: break-all;\" width=\"800\">\n<thead>\n<tr>\n<th style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top; text-align: center; font-weight: bold; color: #4870ac; background: #f7f7f7;\">\u53d8\u91cf<\/th>\n<th style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top; text-align: center; font-weight: bold; color: #4870ac; background: #f7f7f7;\">\u542b\u4e49<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">character_set_server<\/td>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">\u9ed8\u8ba4\u7684\u5185\u90e8\u64cd\u4f5c\u5b57\u7b26\u96c6<\/td>\n<\/tr>\n<tr>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">character_set_client<\/td>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">\u5ba2\u6237\u7aef\u6765\u6e90\u6570\u636e\u4f7f\u7528\u7684\u5b57\u7b26\u96c6<\/td>\n<\/tr>\n<tr>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">character_set_connection<\/td>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">\u8fde\u63a5\u5c42\u5b57\u7b26\u96c6<\/td>\n<\/tr>\n<tr>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">character_set_results<\/td>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">\u67e5\u8be2\u7ed3\u679c\u5b57\u7b26\u96c6<\/td>\n<\/tr>\n<tr>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">character_set_database<\/td>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">\u5f53\u524d\u9009\u4e2d\u6570\u636e\u5e93\u7684\u9ed8\u8ba4\u5b57\u7b26\u96c6<\/td>\n<\/tr>\n<tr>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">character_set_system<\/td>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">\u7cfb\u7edf\u5143\u6570\u636e\uff08\u5b57\u6bb5\u540d\u7b49\uff09\u5b57\u7b26\u96c6<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2 style=\"padding: 1px 12.5px; color: #ffffff; margin: 1.2em 0px 1em; border-radius: 4px; display: inline-block; background-color: #4870ac; font-size: 1.3em;\">\u4e8c\u3001\u7ed3\u679c\u5b57\u7b26\u96c6\u8f6c\u6362<\/h2>\n<p style=\"margin: 1em 0px;\">\u64cd\u4f5c\u7ed3\u679c\u4f1a\u4ece\u5185\u90e8\u64cd\u4f5c\u5b57\u7b26\u96c6\u8f6c\u6362\u6210 <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">character_set_results<\/code>\uff1a<\/p>\n<p style=\"margin: 1em 0px;\"><a href=\"https:\/\/ai.zhousir.top\/wp-content\/uploads\/2017\/08\/mysqlcharset.jpeg\" rel=\"fancybox\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-2153\" src=\"https:\/\/ai.zhousir.top\/wp-content\/uploads\/2017\/08\/mysqlcharset.jpeg\" alt=\"mysqlcharset\" width=\"426\" height=\"373\" \/><\/a><\/p>\n<h2 style=\"padding: 1px 12.5px; color: #ffffff; margin: 1.2em 0px 1em; border-radius: 4px; display: inline-block; background-color: #4870ac; font-size: 1.3em;\">\u4e09\u3001\u9ed8\u8ba4\u5b57\u7b26\u96c6\u4ece\u54ea\u6765<\/h2>\n<p style=\"margin: 1em 0px;\">\u5b57\u7b26\u96c6\u53ef\u4ee5\u7ec6\u5230\u5e93\u3001\u8868\u3001\u5217\u3002\u6ca1\u914d\u590d\u6742\u9009\u9879\u65f6\u8d70\u9ed8\u8ba4\uff1a<\/p>\n<ul style=\"padding-left: 1rem; margin-left: 1rem; font-size: 0.9rem; list-style-type: disc;\">\n<li>\n<section>\u7f16\u8bd1 MySQL \u65f6\u6307\u5b9a\u9ed8\u8ba4\u5b57\u7b26\u96c6\uff0c\u8fd9\u4e2a\u503c\u662f <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">latin1<\/code>\u3002<\/section>\n<\/li>\n<li>\n<section>\u5b89\u88c5\u65f6\u53ef\u4ee5\u5728\u914d\u7f6e\u6587\u4ef6 <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">my.ini<\/code> \u91cc\u6307\u5b9a\uff1b\u6ca1\u6307\u5b9a\u5c31\u7ee7\u627f\u7f16\u8bd1\u65f6\u7684\u503c\u3002<\/section>\n<\/li>\n<li>\n<section>\u542f\u52a8 mysqld \u65f6\u53ef\u4ee5\u5728\u547d\u4ee4\u884c\u6307\u5b9a\uff1b\u6ca1\u6307\u5b9a\u5c31\u7ee7\u627f\u914d\u7f6e\u6587\u4ef6\uff0c\u6b64\u65f6 <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">character_set_server<\/code> \u88ab\u8bbe\u4e3a\u8fd9\u4e2a\u9ed8\u8ba4\u5b57\u7b26\u96c6\u3002<\/section>\n<\/li>\n<li>\n<section>\u5b89\u88c5\u65f6\u82e5\u9009\u591a\u8bed\u8a00\u652f\u6301\uff0c\u5b89\u88c5\u7a0b\u5e8f\u4f1a\u81ea\u52a8\u5728\u914d\u7f6e\u6587\u4ef6\u628a <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">default_character_set<\/code> \u8bbe\u4e3a UTF-8\uff0c\u4fdd\u8bc1\u7f3a\u7701\u4e0b\u5e93\u3001\u8868\u3001\u5217\u90fd\u7528 UTF-8 \u5b58\u50a8\u3002<\/section>\n<\/li>\n<\/ul>\n<p style=\"margin: 1em 0px;\">\u9ed8\u8ba4\u60c5\u51b5\u4e0b MySQL \u5b57\u7b26\u96c6\u662f latin1\uff08ISO_8859_1\uff09\u3002<\/p>\n<h2 style=\"padding: 1px 12.5px; color: #ffffff; margin: 1.2em 0px 1em; border-radius: 4px; display: inline-block; background-color: #4870ac; font-size: 1.3em;\">\u56db\u3001\u4fee\u6539\u9ed8\u8ba4\u5b57\u7b26\u96c6<\/h2>\n<h3 style=\"padding: 0px; color: #4870ac; margin: 1.2em 0px 1em; font-size: 1.3em;\">1. \u6539 my.ini<\/h3>\n<p style=\"margin: 1em 0px;\">\u6700\u7b80\u5355\u7684\u529e\u6cd5\u662f\u6539 mysql \u7684 <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">my.ini<\/code> \u91cc\u7684\u5b57\u7b26\u96c6\u952e\u503c\uff0c\u4f8b\u5982\uff1a<\/p>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 12px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; overflow-x: auto; margin: 0.5em; padding: 3px 5px; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">default-character-set = utf8\ncharacter_set_server = utf8<\/code><\/pre>\n<p style=\"margin: 1em 0px;\">\u6539\u5b8c\u540e\u91cd\u542f mysql \u670d\u52a1\u3002<\/p>\n<h3 style=\"padding: 0px; color: #4870ac; margin: 1.2em 0px 1em; font-size: 1.3em;\">2. \u7528 SQL \u547d\u4ee4<\/h3>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 12px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; overflow-x: auto; margin: 0.5em; padding: 3px 5px; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">mysql&gt; SET character_set_client = utf8 ;\nmysql&gt; SET character_set_connection = utf8 ;\nmysql&gt; SET character_set_database = utf8 ;\nmysql&gt; SET character_set_results = utf8 ;\nmysql&gt; SET character_set_server = utf8 ;\nmysql&gt; SET collation_connection = utf8 ;\nmysql&gt; SET collation_database = utf8 ;\nmysql&gt; SET collation_server = utf8 ;<\/code><\/pre>\n<p style=\"margin: 1em 0px;\">\u8868\u7684\u9ed8\u8ba4\u5b57\u7b26\u96c6\u5df2\u7ecf\u662f utf8\uff0c\u67e5\u8be2\u4e5f\u7528 UTF-8 \u53d1\u51fa\u53bb\uff0c\u5165\u5e93\u4ecd\u4e71\u7801\uff0c\u591a\u534a\u662f <strong style=\"color: #4870ac;\">connection<\/strong> \u8fde\u63a5\u5c42\u7684\u95ee\u9898\u3002\u53d1\u9001\u67e5\u8be2\u524d\u6267\u884c\uff1a<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">SET NAMES 'utf8';<\/code> \u5b83\u76f8\u5f53\u4e8e\u4e0b\u9762\u4e09\u53e5\uff1a<\/p>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 12px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; overflow-x: auto; margin: 0.5em; padding: 3px 5px; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">SET character_set_client = utf8;\nSET character_set_results = utf8;\nSET character_set_connection = utf8;<\/code><\/pre>\n<blockquote style=\"display: block; font-size: 0.9em; border-left: 3px solid #4870ac; padding: 0.5em 1em; margin: 0px; background: #f6f8fa; color: #40464f;\">\n<p style=\"margin: 1em 0px;\"><strong style=\"color: #4870ac;\">\u4e00\u53e5\u8bdd\u603b\u7ed3\uff1aMySQL \u5b57\u7b26\u96c6\u5206 server \/ database \/ table \/ connection \u56db\u5c42\uff1b\u8868\u5df2\u662f utf8 \u4ecd\u4e71\u7801\u65f6\uff0c\u5148 SET NAMES &#8216;utf8&#8217; \u5bf9\u9f50\u8fde\u63a5\u5c42\u3002<\/strong><\/p>\n<\/blockquote>\n<\/section>\n","protected":false},"excerpt":{"rendered":"<p>MySQL \u5bf9\u5b57\u7b26\u96c6\u7684\u652f\u6301\u53ef\u4ee5\u7ec6\u5230\u56db\u4e2a\u5c42\u6b21\uff1a\u670d\u52a1\u5668\uff08server\uff09\u3001\u6570\u636e\u5e93\uff08database\uff09\u3001\u6570\u636e\u8868\uff08tab [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[61],"tags":[192,62,63],"_links":{"self":[{"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/posts\/2152"}],"collection":[{"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2152"}],"version-history":[{"count":3,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/posts\/2152\/revisions"}],"predecessor-version":[{"id":2156,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/posts\/2152\/revisions\/2156"}],"wp:attachment":[{"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2152"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2152"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2152"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}