国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 數(shù)據(jù)庫 > MySQL > 正文

介紹三種查看MySQL字符集的方法

2024-07-24 12:31:49
字體:
供稿:網(wǎng)友
       MySQL字符集設(shè)置
 
        系統(tǒng)變量:
– character_set_server:默認(rèn)的內(nèi)部操作字符集
– character_set_client:客戶端來源數(shù)據(jù)使用的字符集
– character_set_connection:連接層字符集
– character_set_results:查詢結(jié)果字符集
– character_set_database:當(dāng)前選中數(shù)據(jù)庫的默認(rèn)字符集
– character_set_system:系統(tǒng)元數(shù)據(jù)(字段名等)字符集
– 還有以collation_開頭的同上面對應(yīng)的變量,用來描述字符序。
  
       登陸MySQL數(shù)據(jù)庫:
C:/Users/duansf>mysql -u root -p
Enter password: ******
Welcome to the MySQL monitor.  Commands end with ; or /g.
Your MySQL connection id is 4
Server version: 5.5.13 MySQL Community Server (GPL)
  
Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
  
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
  
Type 'help;' or '/h' for help. Type '/c' to clear the current input statement.
  
mysql>
 
一.查看MySQL數(shù)據(jù)庫服務(wù)器和數(shù)據(jù)庫MySQL的字符集:
mysql> show variables like '%char%';
+--------------------------+---------------------------------------------------------------+
| Variable_name            | Value                                                         |
+--------------------------+---------------------------------------------------------------+
| character_set_client     | utf8                                                          |
| character_set_connection | utf8                                                          |
| character_set_database   | gbk                                                           |
| character_set_filesystem | binary                                                        |
| character_set_results    | utf8                                                          |
| character_set_server     | utf8                                                          |
| character_set_system     | utf8                                                          |
| character_sets_dir       | C:/Program Files (x86)/MySQL/MySQL Server 5.5/share/charsets/ |
+--------------------------+---------------------------------------------------------------+
8 rows in set (0.00 sec)
  
二.查看MySQL數(shù)據(jù)表(table)的MySQL字符集:
 
mysql> use test
Database changed
 
mysql> show table status from test like '%work%';
+----------+--------+---------+------------+------+----------------+-------------+-----------------+
--------------+-----------+----------------+---------------------+-------------+------------+-------
----------+----------+----------------+---------+
| Name     | Engine | Version | Row_format | Rows | Avg_row_length | Data_length | Max_data_length |
 Index_length | Data_free | Auto_increment | Create_time         | Update_time | Check_time | Collat
ion       | Checksum | Create_options | Comment |
+----------+--------+---------+------------+------+----------------+-------------+-----------------+
--------------+-----------+----------------+---------------------+-------------+------------+-------
----------+----------+----------------+---------+
| workinfo | InnoDB |      10 | Compact    |    1 |          16384 |       16384 |               0 |
        32768 |   9437184 |              4 | 2016-03-07 16:13:51 | NULL        | NULL       | utf8_g
eneral_ci |     NULL |                |         |
+----------+--------+---------+------------+------+----------------+-------------+-----------------+
--------------+-----------+----------------+---------------------+-------------+------------+-------
----------+----------+----------------+---------+
1 row in set (0.00 sec)
  
三.查看MySQL數(shù)據(jù)列(column)的MySQL字符集:
mysql> show full columns from workinfo;
+----------+-------------+-----------------+------+-----+---------+----------------+----------------
-----------------+---------+
| Field    | Type        | Collation       | Null | Key | Default | Extra          | Privileges
                 | Comment |
+----------+-------------+-----------------+------+-----+---------+----------------+----------------
-----------------+---------+
| id       | int(10)     | NULL            | NO   | PRI | NULL    | auto_increment | select,insert,u
pdate,references |         |
| name     | varchar(20) | utf8_general_ci | NO   |     | NULL    |                | select,insert,u
pdate,references |         |
| type     | varchar(10) | utf8_general_ci | YES  |     | NULL    |                | select,insert,u
pdate,references |         |
| address  | varchar(50) | utf8_general_ci | YES  |     | NULL    |                | select,insert,u
pdate,references |         |
| tel      | varchar(20) | utf8_general_ci | YES  |     | NULL    |                | select,insert,u
pdate,references |         |
| wages    | int(11)     | NULL            | YES  |     | NULL    |                | select,insert,u
pdate,references |         |
| contents | tinytext    | utf8_general_ci | YES  |     | NULL    |                | select,insert,u
pdate,references |         |
| extra    | text        | utf8_general_ci | YES  |     | NULL    |                | select,insert,u
pdate,references |         |
+----------+-------------+-----------------+------+-----+---------+----------------+----------------
-----------------+---------+
8 rows in set (0.02 sec)
  
       解決字符集通訊設(shè)置不匹配的方法:
(修改默認(rèn)的character_set_client,character_set_connection,character_set_result)
1. 重新編譯mysql和php,mysql加入編譯參數(shù) –default-character-set=utf8
2. PHP程序在查詢數(shù)據(jù)庫之前,執(zhí)行mysql_query(”set names utf8;”);
3.修改my.cnf,在[mysqld]中加入init-connect=”set names utf8” (對于超級用戶連接該選項無效)
4. 啟動mysqld 加入?yún)?shù) –skip-character-set-client-handshake 忽略客戶端字符集。

(編輯:武林網(wǎng))

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 靖西县| 湖口县| 兴城市| 石家庄市| 渑池县| 太保市| 鹤壁市| 建德市| 奇台县| 通道| 大名县| 门源| 民乐县| 舞钢市| 博爱县| 松阳县| 内丘县| 寻甸| 广河县| 兴隆县| 成武县| 辛集市| 卫辉市| 团风县| 枣庄市| 余庆县| 越西县| 绥江县| 遵义县| 邵阳市| 宜兴市| 奉贤区| 崇文区| 盈江县| 铜梁县| 两当县| 库伦旗| 内黄县| 崇义县| 罗山县| 顺昌县|