[MySQL FAQ]系列 -- 如何更改MySQL的默认字符集

方法1、 用 SET 语法来指定,不加 "GLOBAL" 的话就只对本次会话有效

SET [GLOBAL] character_set_client     = utf8;
SET [GLOBAL] character_set_connection = utf8;
SET [GLOBAL] character_set_database   = utf8;
SET [GLOBAL] character_set_results    = utf8;
SET [GLOBAL] character_set_server     = utf8;

方法2、 也用SET语法,只对本次会话有效

SET NAMES 'utf8';

方法3、) 直接修改 my.cnf,增加一行内容,然后重启 MySQL,使之全局生效

default-character-set = utf8

回复

此内容将保密,不会被其他人看见。
  • 允许的 HTML 标签: <a> <b> <address> <blockquote> <br> <caption> <center> <code> <dd> <del> <div> <dl> <dt> <em> <font> <h2> <h3> <h4> <h5> <h6> <hr> <i> <img> <li> <ol> <p> <pre> <span> <strong> <sub> <sup> <table> <tbody> <td> <tfoot> <th> <thead> <tr> <u> <ul> <tr>
  • 行和段被自动切分。
  • 网页地址和电子邮件地址将会被自动转换为链接。

更多格式化选项信息

随机验证
本功能用于防止垃圾信息
在输入框中输入图片上的字符(注意大小写)