查看mysql编码、数据表编码

发布时间:2020-03-13编辑:脚本学堂
本文介绍了mysql数据库与表编码的查看方法,如何查看mysql数据库编码,有需要的朋友可以参考下本节的实例。

本节内容:
mysql/ target=_blank class=infotextkey>mysql数据库编码,mysql表编码的查看实例。

1,查看mysql的编码
 

复制代码 代码示例:
mysql>  show variables like 'character%';                     
+--------------------------+----------------------------+ 
| Variable_name            | Value                      | 
+--------------------------+----------------------------+ 
| character_set_client     | latin1                     |  
| character_set_connection | latin1                     |  
| character_set_database   |<span style="color:#ff0000;"> utf8  </span>                     |  
| character_set_filesystem | binary                     |  
| character_set_results    | latin1                     |  
| character_set_server     | gbk                        |  
| character_set_system     | utf8                       |  
| character_sets_dir       | /u01/mysql/share/charsets/ |  
+--------------------------+----------------------------+ 

2,查看db的编码
 

复制代码 代码示例:
mysql> show create database site001; 
+----------+------------------------------------------------------------------+ 
| Database | Create Database                                                  | 
+----------+------------------------------------------------------------------+ 
| site001  | CREATE DATABASE `site001` /*!40100 <span style="color:#ff0000;">DEFAULT CHARACTER SET utf8</span> */ |  
+----------+------------------------------------------------------------------+ 
1 row in set (0.00 sec) 

3,查看表的编码
 

复制代码 代码示例:
mysql> show create table site_user_page G; 
*************************** 1. row *************************** 
       Table: site_user_page 
Create Table: CREATE TABLE `site_user_page` ( 
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'pk', 
  `gmt_create` datetime NOT NULL COMMENT '????', 
  `gmt_modified` datetime NOT NULL COMMENT '????', 
  `member_id` varchar(36) NOT NULL COMMENT 'member_id', 
  `page_id` varchar(20) NOT NULL COMMENT 'page_id', 
  `head` text COMMENT '??', 
  `content` text COMMENT 'content', 
  `fly` text COMMENT 'fly', 
  `foot` text COMMENT 'foot', 
  `instance_key` varchar(32) NOT NULL COMMENT 'instancekey', 
  `user_instance_key` varchar(32) NOT NULL COMMENT 'user_instance_key', 
  `page_type` varchar(32) DEFAULT NULL, 
  PRIMARY KEY (`id`), 
  KEY `idx_userInstanceKey` (`user_instance_key`), 
  KEY `idx_instanceKey` (`instance_key`), 
  KEY `idx_userInstanceKey_pageid` (`user_instance_key`,`page_id`), 
  KEY `idx_memberId` (`member_id`) 
) ENGINE=innodb AUTO_INCREMENT=101820722 <span style="color:#ff0000;">DEFAULT CHARSET=utf8</span> 
1 row in set (0.00 sec)