介紹三種檢視MySQL字符集的方法
MySQL字符集設定
系統變數:
– character_set_server:預設的內部操作字符集
– character_set_client:客戶端來源資料使用的字符集
– character_set_connection:連線層字符集
– character_set_results:查詢結果字符集
– character_set_database:當前選中資料庫的預設字符集
– character_set_system:系統後設資料(欄位名等)字符集
– 還有以collation_開頭的同上面對應的變數,用來描述字元序。
登陸MySQL資料庫:
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資料庫伺服器和資料庫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資料表(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資料列(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)
解決字符集通訊設定不匹配的方法:
(修改預設的character_set_client,character_set_connection,character_set_result)
1. 重新編譯mysql和php,mysql加入編譯引數 –default-character-set=utf8
2. PHP程式在查詢資料庫之前,執行mysql_query(”set names utf8;”);
3.修改my.cnf,在[mysqld]中加入init-connect=”set names utf8” (對於超級使用者連線該選項無效)
4. 啟動mysqld 加入引數 –skip-character-set-client-handshake 忽略客戶端字符集
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/15498/viewspace-2120723/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- MySQL檢視版本號的五種方式介紹MySql
- MySQL檢視介紹MySql
- MySQL檢視和修改字符集的方法MySql
- 檢視mysql版本的六種方法MySql
- linux下檢視mysql版本的四種方法LinuxMySql
- mysql鎖之三種行級鎖介紹MySql
- MySQL 檢視與修改預設字符集MySql
- MySQL 檢視簡介MySql
- Linux系統下檢視mysql版本的四種方法LinuxMySql
- 使用命令檢視Linux核心版本的三種方法Linux
- 簡單介紹Golang切片刪除指定元素的三種方法Golang
- 中科三方:三種檢視SSL證書有效期的方法
- SQL隱碼攻擊的檢測方式有幾種?常用方法介紹!SQL
- Android中圖片圓形設定三種方法介紹Android
- MySQL檢視簡介與操作MySql
- vue2.0資料更新,重新渲染檢視的三種方法Vue
- 介紹幾種提高mysql的效能和對於sql的優化的方法MySql優化
- 代理IP檢測的三種方法
- 資產納管的三種方式介紹
- MongoDB三種聚合命令用法介紹MongoDB
- 電腦配置的三種檢視方法 不用藉助軟體怎麼檢視電腦配置
- MySQL事務提交的三個階段介紹MySql
- iOS開發-列表檢視的基本介紹與使用iOS
- SAP ABAP CDS view 檢視的 Replacement 技術介紹View
- 介紹幾種MySQL常見的圖形化工具MySql
- 簡單介紹MySQL索引失效的幾種情況MySql索引
- MySQL線上新增欄位的幾種方案介紹MySql
- 四種大資料分析方法介紹!大資料
- Linux檢視檔案大小的幾種方法Linux
- mysql檢視主從同步狀態的方法MySql主從同步
- MySql介紹MySql
- Android上一種效果奇好的混音方法介紹Android
- 簡單介紹MySQL開啟事務的兩種方式MySql
- 前端跨域有哪些種方法及介紹?前端跨域
- CentOS下檢視系統版本的4種方法CentOS
- MVC 檢視不使用模板頁的兩種方法MVC
- 簡單介紹MySQL列印死鎖日誌的方法MySql
- 怎麼看電腦是win幾的系統 電腦檢視windows版本方法介紹Windows
- 印表機ip地址哪裡看 印表機ip地址和埠檢視方法介紹