Maison >base de données >tutoriel mysql >MySQL字符集中所设定参数
以下的文章主要描述的是MySQL字符集中所设定的所有相关参数UTF8,我们在安装完成之后已经MySQL字符集(和PHP搭配之最佳组合)进行设置 ,把它设置为utf8。具体的操作内容如下,望你会有所领悟。 但是 MySQL(和PHP搭配之最佳组合) SHOWVARIABLESLIKE'collation_
以下的文章主要描述的是MySQL字符集中所设定的所有相关参数UTF8,我们在安装完成之后已经MySQL字符集(和PHP搭配之最佳组合)进行设置 ,把它设置为utf8。具体的操作内容如下,望你会有所领悟。
但是
<ol class="dp-xml"> <li class="alt"><span><span>MySQL(和PHP搭配之最佳组合)</span><span class="tag">></span><span> SHOW VARIABLES LIKE 'collation_%'; </span></span></li> <li><span>+----------------------+-------------------+ </span></li> <li class="alt"><span>| Variable_name | Value | </span></li> <li><span>+----------------------+-------------------+ </span></li> <li class="alt"><span>| collation_connection | latin1_swedish_ci | </span></li> <li><span>| collation_database | utf8_general_ci | </span></li> <li class="alt"><span>| collation_server | utf8_general_ci | </span></li> <li><span>+----------------------+-------------------+ </span></li> <li class="alt"><span>3 rows in set (0.00 sec) </span></li> <li><span> </span></li> <li class="alt"> <span>MySQL(和PHP搭配之最佳组合)</span><span class="tag">></span><span> SHOW VARIABLES LIKE 'character_set_%'; </span> </li> <li><span>+--------------------------+------------------------------------------------+ </span></li> <li class="alt"><span>| Variable_name | Value | </span></li> <li><span>+--------------------------+------------------------------------------------+ </span></li> <li class="alt"><span>| character_set_client | latin1 | </span></li> <li><span>| character_set_connection | latin1 | </span></li> <li class="alt"><span>| character_set_database | utf8 | </span></li> <li><span>| character_set_results | latin1 | </span></li> <li class="alt"><span>| character_set_server | utf8 | </span></li> <li><span>| character_set_system | utf8 | </span></li> <li class="alt"><span>| character_sets_dir | D:\data\MySQL(和PHP搭配之最佳组合)\MySQL(和PHP搭配之最佳组合) Server 4.1\share\charsets/ | </span></li> <li><span>+--------------------------+------------------------------------------------+ </span></li> <li class="alt"><span>7 rows in set (0.00 sec) </span></li> </ol>
发觉画线标注的属性还是非 utf8的。
然后修改 my.ini 文件,设置
以下是代码片段:
<ol class="dp-xml"> <li class="alt"><span><span>[client] </span></span></li> <li> <span class="attribute">default-character-set</span><span>=</span><span class="attribute-value">utf8</span><span> </span> </li> <li class="alt"><span>[MySQL(和PHP搭配之最佳组合)] </span></li> <li> <span class="attribute">default-character-set</span><span>=</span><span class="attribute-value">utf8</span><span> </span> </li> <li class="alt"><span>[MySQL(和PHP搭配之最佳组合)d] </span></li> <li> <span class="attribute">default-character-set</span><span>=</span><span class="attribute-value">utf8</span><span> </span> </li> <li class="alt"><span> </span></li> </ol>
copy my.ini 文件到 windows目录
启动MySQL字符集(和PHP搭配之最佳组合) 以下是代码片段:
<ol class="dp-xml"> <li class="alt"><span><span>MySQL(和PHP搭配之最佳组合)</span><span class="tag">></span><span> SHOW VARIABLES LIKE ’character_set_%’; </span></span></li> <li><span>+--------------------------+------------------------------------------------+ </span></li> <li class="alt"><span>| Variable_name | Value | </span></li> <li><span>+--------------------------+------------------------------------------------+ </span></li> <li class="alt"><span>| character_set_client | utf8 | </span></li> <li><span>| character_set_connection | utf8 | </span></li> <li class="alt"><span>| character_set_database | utf8 | </span></li> <li><span>| character_set_results | utf8 | </span></li> <li class="alt"><span>| character_set_server | utf8 | </span></li> <li><span>| character_set_system | utf8 | </span></li> <li class="alt"><span>| character_sets_dir | D:\data\MySQL(和PHP搭配之最佳组合)\MySQL(和PHP搭配之最佳组合) Server 4.1\share\charsets/ | </span></li> <li><span>+--------------------------+------------------------------------------------+ </span></li> <li class="alt"><span>7 rows in set (0.00 sec) </span></li> <li><span> </span></li> <li class="alt"> <span>MySQL(和PHP搭配之最佳组合)</span><span class="tag">></span><span> SHOW VARIABLES LIKE ’character_set_%’; </span> </li> <li><span>+--------------------------+------------------------------------------------+ </span></li> <li class="alt"><span>| Variable_name | Value | </span></li> <li><span>+--------------------------+------------------------------------------------+ </span></li> <li class="alt"><span>| character_set_client | utf8 | </span></li> <li><span>| character_set_connection | utf8 | </span></li> <li class="alt"><span>| character_set_database | utf8 | </span></li> <li><span>| character_set_results | utf8 | </span></li> <li class="alt"><span>| character_set_server | utf8 | </span></li> <li><span>| character_set_system | utf8 | </span></li> <li class="alt"><span>| character_sets_dir | D:\data\MySQL(和PHP搭配之最佳组合)\MySQL(和PHP搭配之最佳组合) Server 4.1\share\charsets/ | </span></li> <li><span>+--------------------------+------------------------------------------------+ </span></li> <li class="alt"><span>7 rows in set (0.00 sec) </span></li> </ol>
一切正常了。创建数据库:以下是代码片段:
<ol class="dp-xml"> <li class="alt"><span><span>create table t_sysuser ( </span></span></li> <li><span>USERID integer not null auto_increment, </span></li> <li class="alt"><span>USERNAME varchar(30), </span></li> <li><span>PASSWORDS varchar(30), </span></li> <li class="alt"><span>DEPTNO varchar(30), </span></li> <li><span>HEADSHIP varchar(30), </span></li> <li class="alt"><span>SEX varchar(4), </span></li> <li><span>TEL varchar(18), </span></li> <li class="alt"><span>EMAIL varchar(30), </span></li> <li><span>URL varchar(30), </span></li> <li class="alt"><span>PCALL varchar(20), </span></li> <li><span>USERPHOTO varchar(255), </span></li> <li class="alt"><span>FACEREFUTIME integer, </span></li> <li><span>FACELANGUAGE varchar(1), </span></li> <li class="alt"><span>LASTMODIF varchar(30), </span></li> <li><span>LASTMDATE datetime, </span></li> <li class="alt"><span>CREADTOR varchar(30), </span></li> <li><span>CREATDATE datetime, </span></li> <li class="alt"><span>Prima(最完善的虚拟主机管理系统)ry key (USERID) </span></li> <li> <span>) </span><span class="attribute">ENGINE</span><span>=</span><span class="attribute-value">InnoDB</span><span> DEFAULT </span><span class="attribute">CHARSET</span><span>=</span><span class="attribute-value">utf8</span><span>; </span> </li> </ol>
全部搞定。