{"id":47,"date":"2019-07-17T01:09:00","date_gmt":"2019-07-17T01:09:00","guid":{"rendered":"http:\/\/pro369.com\/sale\/?p=47"},"modified":"2019-07-17T01:09:00","modified_gmt":"2019-07-17T01:09:00","slug":"%e6%9e%b6%e8%a8%ad%e7%b6%b2%e7%ab%99%e6%9c%83%e5%87%ba%e7%8f%be%e4%ba%82%e7%a2%bc%e7%9a%84%e5%8e%9f%e5%9b%a0%ef%bc%88mysql%e4%b8%ad%e6%96%87%e4%ba%82%e7%a2%bc%ef%bc%89","status":"publish","type":"post","link":"https:\/\/por.tw\/sale\/%e6%9e%b6%e8%a8%ad%e7%b6%b2%e7%ab%99%e6%9c%83%e5%87%ba%e7%8f%be%e4%ba%82%e7%a2%bc%e7%9a%84%e5%8e%9f%e5%9b%a0%ef%bc%88mysql%e4%b8%ad%e6%96%87%e4%ba%82%e7%a2%bc%ef%bc%89\/","title":{"rendered":"\u67b6\u8a2d\u7db2\u7ad9\u6703\u51fa\u73fe\u4e82\u78bc\u7684\u539f\u56e0\uff08mysql\u4e2d\u6587\u4e82\u78bc\uff09"},"content":{"rendered":"<p><strong><span style=\"font-size: 16px;\"><span style=\"color: #ff00ff;\"><span style=\"font-size: 24px;\">\u67b6\u8a2d\u7db2\u7ad9\u6703\u51fa\u73fe\u4e82\u78bc\u7684\u539f\u56e0\uff08mysql\u4e2d\u6587\u4e82\u78bc\uff09<\/span><br \/>\n<img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/visdacom.com\/sale\/wp-content\/uploads\/2014\/04\/2018-6-15-09-57-37.png\" alt=\"\" class=\"alignnone size-full wp-image-539\" width=\"700\" height=\"414\" srcset=\"https:\/\/por.tw\/sale\/wp-content\/uploads\/2014\/04\/2018-6-15-09-57-37.png 700w, https:\/\/por.tw\/sale\/wp-content\/uploads\/2014\/04\/2018-6-15-09-57-37-650x384.png 650w, https:\/\/por.tw\/sale\/wp-content\/uploads\/2014\/04\/2018-6-15-09-57-37-262x155.png 262w, https:\/\/por.tw\/sale\/wp-content\/uploads\/2014\/04\/2018-6-15-09-57-37-304x180.png 304w\" sizes=\"(max-width: 700px) 100vw, 700px\" \/><br \/>\n<\/span><\/span><\/strong><br \/>\n<strong><span style=\"font-size: 16px;\"><span style=\"color: #ff00ff;\">\u3010mysql\u4e2d\u6587\u4e82\u78bc\u7684\u539f\u56e0\u3011\uff1a<\/span><br \/>\nmysql \u6703\u51fa\u73fe\u4e2d\u6587\u4e82\u78bc\u7684\u539f\u56e0\u4e0d\u5916\u4e4e\u4e0b\u5217\u5e7e\u9ede\uff1a<\/span><\/strong><br \/>\n<strong><span style=\"font-size: 16px;\"><span style=\"color: #0000ff;\">1. mysql server\u672c\u8eab\u8a2d\u5b9a\u554f\u984c\uff0c\u4f8b\u5982\u9084\u505c\u7559\u5728 latin1<\/span><\/span><\/strong><br \/>\n<strong><span style=\"font-size: 16px;\"><span style=\"color: #0000ff;\">2. mysql table \u7684\u8a9e\u7cfb\u8a2d\u5b9a\u554f\u984c(\u5305\u542b character \u8207 collation)<\/span><\/span><\/strong><br \/>\n<strong><span style=\"font-size: 16px;\"><span style=\"color: #0000ff;\">3. \u5ba2\u6236\u7aef\u7a0b\u5f0f(\u4f8b\u5982 php) \u7684\u9023\u7dda\u8a9e\u7cfb\u8a2d\u5b9a\u554f\u984c<\/span><\/span><\/strong><br \/>\n<strong><span style=\"font-size: 16px;\"><span style=\"color: #ff00ff;\">mysql 4.1 \u53ca\u4e4b\u5f8c\u7684\u7248\u672c\u5728\u8a9e\u7cfb\u65b9\u9762\u589e\u52a0\u4e86\u8a31\u591a\u529f\u80fd\uff0c\u5b83\u53ef\u4ee5\u8a2d\u5b9a\u8a9e\u7cfb\u7684\u5c64\u6b21\u5f9e\u6700\u5e95\u5c64\u7684 server, database \u5230\u55ae\u4e00 table, column, connection \u90fd\u53ef\u4ee5\u8a2d\u5b9a\uff0c\u800c\u9664\u4e86\u8a9e\u7cfb\u4e4b\u5916\uff0c\u9084\u53ef\u4ee5\u6307\u5b9a\u642d\u914d\u4e0d\u540c\u7684 collation(\u6821\u5c0d)\uff0c\u6240\u4ee5\u7d44\u5408\u767e\u767e\u7a2e\uff0c\u53ea\u8981\u4e00\u500b\u932f\u4e86\u5c31\u96e3\u9003\u4e82\u78bc\u7684\u547d\u904b\u3002<\/span><\/span><\/strong><br \/>\n<strong><span style=\"font-size: 16px;\">\u9032phpmyadmin\u627e\u5230\u53ef\u8f38\u5165 sql query\u7684\u756b\u9762\uff0c\u7136\u5f8c\u9375\u5165\uff1a<br \/>\nshow variables like &#8216;%character%&#8217;;<br \/>\n\u9019\u53e5\u8a71\u6703\u986f\u793a\u76ee\u524d\u8cc7\u6599\u5eab\u4f7f\u7528\u7684\u8a9e\u7cfb\u8a2d\u5b9a\uff0c\u4e00\u822c\u570b\u5916\u7684\u7db2\u7ad9\u6216\u525b\u88dd\u597d\u7684 mysql 4.1\u9810\u8a2d\u90fd\u662f latin-1\u3002<\/span><\/strong><br \/>\n<strong><span style=\"font-size: 16px;\"><span style=\"color: #ff0000;\">[\u65b0\u589e\u8cc7\u6599\u5eab]<\/span><br \/>\n\u5982\u679c\u4f60\u719f\u6089 phpmyadmin \u7684\u64cd\u4f5c\uff0c\u5728\u756b\u9762\u4e0a\u5c31\u53ef\u4ee5\u9078\u64c7\u5efa\u7acb\u65b0 database \u8981\u7528\u7684\u8a9e\u7cfb\uff0c<br \/>\ncharset \u8acb\u9078\u64c7 UTF-8 Unicode (utf8)<br \/>\ncollation \u8acb\u9078\u64c7 utf8_general_ci (ci \u4ee3\u8868 case insensitve \u5927\u5c0f\u5beb\u6c92\u5dee)<\/span><\/strong><br \/>\n<strong><span style=\"font-size: 16px;\"><span style=\"color: #ff0000;\">[\u4fee\u6539\u8cc7\u6599\u5eab]<\/span><br \/>\n\u6539 database\u8a9e\u7cfb\uff0c\u540c\u6a23\u5728 phpmyadmin \u7684query\u756b\u9762\u9375\u5165\u4e0b\u9762\u5169\u884c\uff1a<br \/>\nalter database myblog<br \/>\ncharacter set utf8;<\/span><\/strong><br \/>\n<strong><span style=\"font-size: 16px;\"><span style=\"color: #ff00ff;\">\u524d\u9762\u66fe\u7d93\u63d0\u904e\uff0cmysql\u7684\u8a9e\u7cfb\u8a2d\u5b9a\u662f\u591a\u5c64\u6b21\u7684\uff0c\u524d\u9762\u6211\u5011\u628adatabase\u8207table\u7684\u8a9e\u7cfb\u90fd\u8a2d\u5b9a\u6b63\u78ba\uff0c\u4f46\u7a0b\u5f0f\u8207mysql\u9023\u7dda\u6642\u7684\u8a9e\u7cfb\u5247\u662f\u7531 connection \u4f86\u6c7a\u5b9a\uff0c\u9019\u90e8\u4efd\u5c31\u8981\u4f7f\u7528\u7a0b\u5f0f\u78bc<br \/>\n<\/span>mysql_query(&#8220;SET NAMES &#8216;utf8&#8242;&#8221;);<br \/>\n\u9019\u53e5\u8a71\u6703\u540c\u6642\u8a2d\u5b9a client, results, connection\u4e09\u8005\u4f7f\u7528\u7684\u8a9e\u7cfb\u70ba utf-8\u3002<\/span><\/strong><br \/>\n<strong><span style=\"font-size: 16px;\">\u6700\u5f8c\u6aa2\u67e5\u662f\u5426\u5168\u90e8\u6539\u6210 utf-8<br \/>\nshow variables like &#8216;%character%&#8217;;<\/span><\/strong><br \/>\n<strong><span style=\"font-size: 16px;\"><span style=\"color: #0000ff;\">\u6b64\u6642\u4f60\u61c9\u8a72\u6703\u770b\u5230\u5927\u90e8\u4efd\u6b04\u4f4d\u90fd\u662futf-8\u4e86\uff0c\u9664\u4e86 server \u9019\u9805\u4e4b\u5916\uff0c\u5982\u679c\u662f\u7528\u5225\u4eba\u7684 hosting \u4e3b\u6a5f\uff0c\u5c31\u6c92\u6cd5\u5152\u6539\u9019\u90e8\u4efd\uff0c\u4f46\u5e73\u5e38\u505a\u6848\u5b50\u6642\u5927\u90e8\u4efd\u90fd\u53ef\u4ee5\u76f4\u63a5\u63a7\u7ba1mysql\uff0c\u6b64\u6642\u5c31\u53ef\u4ee5\u7528 my.ini \u8a2d\u5b9a\uff1a<\/span><\/span><\/strong><br \/>\n<strong><span style=\"font-size: 16px;\">[mysqld]<br \/>\ndefault-character-set=utf8<br \/>\n\u544a\u8a34mysql server\u555f\u52d5\u6642\u8981\u7528 utf-8\u5373\u53ef\u3002<\/span><\/strong><br \/>\n&nbsp;<br \/>\n<strong><span style=\"font-size: 16px;\"><span style=\"color: #ff00ff;\">mysql\u4e2d\u6587\u4e82\u78bc\u5fc5\u52dd\u89e3\u6c7a\u6cd5<br \/>\n<\/span><span style=\"color: #0000ff;\">1\u3001mysql \u555f\u52d5\u6642\u6703\u8b80\u53d6\u4e00\u500b\u9810\u8a2d\u7684 config \u6a94\uff0c\u4e00\u822c\u540d\u7a31\u70ba my.ini\uff0c\u800c\u5b83\u6703\u5230\u4e0b\u5217\u5169\u4f4d\u7f6e\u53bb\u5c0b\u627e\u9019\u500b\u6a94\u6848\uff1a<\/span><br \/>\nC:windowsmy.ini \u4e5f\u5c31\u662f\u4f5c\u696d\u7cfb\u7d71\u7684\u5b89\u88dd\u76ee\u9304\uff0c\u4e5f\u6709\u53ef\u80fd\u662f\u4e5f\u5c31\u662f C disk \u7684\u6839\u76ee\u9304<\/span><\/strong><br \/>\n<strong><span style=\"font-size: 16px;\"><span style=\"color: #0000ff;\">2\u3001my.ini \u88cf\u7684\u5167\u5bb9\u70ba\uff1a<\/span><br \/>\n[mysqld]<br \/>\ndefault-character-set=utf8<\/span><\/strong><br \/>\n<strong><span style=\"font-size: 16px;\">[client]<br \/>\ndefault-character-set=utf8<br \/>\ninit_c<\/span><\/strong><br \/>\n<strong><span style=\"font-size: 16px;\">\u5176\u4e2d mysqld \u662f\u6307\u5b9a server \u555f\u52d5\u6642\u8981\u7528\u7684\u8a9e\u7cfb\uff0c\u4f46\u5982\u679c\u9019\u88cf\u8a2d\u5b9a\u70ba utf8 \u53ef\u80fd\u6703\u8b93\u8a31\u591a\u82f1\u6587\u8edf\u9ad4\u4e0d\u958b\u5fc3\uff0c\u4f8b\u5982 osCommerce\/mediaWiki\/wordpress\/drupal\/gregarius\uff0c\u6240\u4ee5\u9019\u88cf\u5efa\u8b70\u8a2d\u6210 latin1\u3002\u8981\u4f7f\u7528utf8\u4e2d\u6587\u7684\u4eba\uff0c\u53ea\u8981\u8a18\u5f97\u5efa\u8cc7\u6599\u5eab\u6642\u5c07\u5b83\u8a2d\u6210utf8\uff0c\u8b93\u4e2d\u6587\u7a0b\u5f0f\u6b63\u78ba\u7684\u4f7f\u7528 utf8 \u8207\u5b83\u6e9d\u901a\u5373\u53ef\u3002<\/span><\/strong><br \/>\n<strong><span style=\"font-size: 16px;\">\u4e0b\u9762\u7684 client \u5247\u662f\u8a2d\u5b9a\u7576 client \u9023\u7dda\u6642\u8981\u4f7f\u7528\u4ec0\u9ebc\u8a9e\u7cfb\uff0c\u4f46\u53ef\u60dc\u7684\u662f\u9019\u500b\u8a2d\u5b9a\u4e0d\u662f\u6bcf\u500b client \u90fd\u6703\u9ce5\u5b83\uff0c\u57fa\u672c\u4e0a\u53ea\u6709 mysql \u81ea\u5df2\u5bb6\u7684\u7a0b\u5f0f\uff0c\u4f8b\u5982 mysql.exe, mysqld.exe, mysqladmin.exe \u6216\u662f MySQL Control Center \u9019\u7a2e\u7a0b\u5f0f\u6703\u53bb\u8b80\u53d6\u9019\u500b\u8a2d\u5b9a\u6a94\u7136\u5f8c\u6539\u7528 utf8 \u9023\u7dda\u3002<\/span><\/strong><br \/>\n<strong><span style=\"font-size: 16px;\">\u6240\u4ee5\u901a\u5e38\u6703\u7528\u4e00\u500b\u7368\u7acb\u7684\u6a94\u6848\u4f86\u8655\u7406 mysql connection\u7684\u8a2d\u5b9a\uff0c\u4f8b\u5982\uff1a<\/span><\/strong><br \/>\n<strong><span style=\"font-size: 16px;\">PHP:<br \/>\n<code><br \/>\n&lt;?<br \/>\n\/\/database connection details.<br \/>\n$host = \"localhost\";<br \/>\n$link = mysql_connect($host, \"xxx\", \"xxx\");<br \/>\nmysql_query(\"SET NAMES 'utf8'\");<br \/>\nmysql_select_db(\"your_table_name_here\", $link);<br \/>\n?&gt;<br \/>\n<\/code><\/span><\/strong><br \/>\n<strong><span style=\"font-size: 16px;\">\u8acb\u6ce8\u610f\u5728 mysql_connect\u5f8c\u7b2c\u4e94\u884c\u7684\u5730\u65b9\u6709\u52a0\u4e0a\u4e00\u500b &#8220;set names &#8216;utf8&#8217; &#8220;\u7684\u6307\u4ee4\uff0c\u544a\u8a34mysql \u9019\u500b connection \u4e4b\u5f8c\u7684\u9023\u7dda\u5167\u5bb9\u90fd\u8981\u4f7f\u7528utf8\uff0c\u7d93\u904e\u9019\u6a23\u8a2d\u5b9a\u5f8c\uff0c\u901a\u5e38\u5c31\u53ef\u4ee5\u89e3\u6c7a\u5927\u90e8\u4efd\u554f\u984c\u3002<\/span><\/strong><br \/>\n<strong><span style=\"font-size: 16px;\">\u5f9e\u9019\u88cf\u4e5f\u53ef\u4ee5\u63a8\u60f3\u5f97\u77e5\uff0c\u5982\u679c\u4f60\u6709\u7528\u67d0\u7a2e custom connection pooling \u6a5f\u5236\uff0c\u5c31\u8981\u8a18\u5f97\u5728\u6bcf\u6b21\u5efa\u7acb\u65b0\u7684 connection \u5f8c\u7acb\u5373\u8a2d\u5b9a\u70ba utf8\u3002<br \/>\n<\/span><\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u67b6\u8a2d\u7db2\u7ad9\u6703\u51fa\u73fe\u4e82\u78bc\u7684\u539f\u56e0\uff08mysql\u4e2d\u6587\u4e82\u78bc\uff09 \u3010mysql\u4e2d\u6587\u4e82\u78bc\u7684\u539f\u56e0\u3011\uff1a mysql \u6703\u51fa\u73fe\u4e2d\u6587\u4e82\u78bc\u7684\u539f [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":539,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[22],"tags":[],"_links":{"self":[{"href":"https:\/\/por.tw\/sale\/wp-json\/wp\/v2\/posts\/47"}],"collection":[{"href":"https:\/\/por.tw\/sale\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/por.tw\/sale\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/por.tw\/sale\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/por.tw\/sale\/wp-json\/wp\/v2\/comments?post=47"}],"version-history":[{"count":0,"href":"https:\/\/por.tw\/sale\/wp-json\/wp\/v2\/posts\/47\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/por.tw\/sale\/wp-json\/wp\/v2\/media\/539"}],"wp:attachment":[{"href":"https:\/\/por.tw\/sale\/wp-json\/wp\/v2\/media?parent=47"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/por.tw\/sale\/wp-json\/wp\/v2\/categories?post=47"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/por.tw\/sale\/wp-json\/wp\/v2\/tags?post=47"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}