版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
1、MySQL 亂碼的根源是的 MySQL 字符集設置不當?shù)膯栴},本文匯總了有關查看 MySQL 字符集的命令。包括查看 MySQL 數(shù)據庫服務器字符集、查看 MySQL 數(shù)據庫字符集,以及數(shù)據表和字段的字符集、當前安裝的 MySQL 所支持的字符集等。 一、查看 MySQL 數(shù)據庫服務器和數(shù)據庫字符集。 mysql> show variables like '%char%'+-+-+-| Variable_name | Value |.+-+-+-| character_set_client | utf8 |. - 客戶端字符集| character_set_connect
2、ion | utf8 |.| character_set_database | utf8 |. - 數(shù)據庫字符集| character_set_filesystem | binary |.| character_set_results | utf8 |.| character_set_server | utf8 |. - 服務器字符集| character_set_system | utf8 |.| character_sets_dir | D:MySQL Server 5.0sharecharsets |.+-+-+-二、查看 MySQL 數(shù)據表(table) 的字符集。 mysql>
3、 show table status from sqlstudy_db like '%countries%'+-+-+-+-+-+-+-| Name | Engine | Version | Row_format | Rows | Collation |.+-+-+-+-+-+-+-| countries | InnoDB | 10 | Compact | 11 | utf8_general_ci |.+-+-+-+-+-+-+-三、查看 MySQL 數(shù)據列(column)的字符集。 mysql> show full columns from countries;+-+-
4、+-+-| Field | Type | Collation | .+-+-+-+-| countries_id | int(11) | NULL | .| countries_name | varchar(64) | utf8_general_ci | .| countries_iso_code_2 | char(2) | utf8_general_ci | .| countries_iso_code_3 | char(3) | utf8_general_ci | .| address_format_id | int(11) | NULL | .+-+-+-+-四、查看當前安裝的 MySQL
5、 所支持的字符集。 mysql> show charset;mysql> show char set;+-+-+-+-+| Charset | Description | Default collation | Maxlen |+-+-+-+-+| big5 | Big5 Traditional Chinese | big5_chinese_ci | 2 | dec8 | DEC West European | dec8_swedish_ci | 1 | cp850 | DOS West European | cp850_general_ci | 1 | hp8 | HP West
6、 European | hp8_english_ci | 1 | koi8r | KOI8-R Relcom Russian | koi8r_general_ci | 1 | latin1 | cp1252 West European | latin1_swedish_ci | 1 | latin2 | ISO 8859-2 Central European | latin2_general_ci | 1 | swe7 | 7bit Swedish | swe7_swedish_ci | 1 | ascii | US ASCII | ascii_general_ci | 1 | ujis |
7、EUC-JP Japanese | ujis_japanese_ci | 3 | sjis | Shift-JIS Japanese | sjis_japanese_ci | 2 | hebrew | ISO 8859-8 Hebrew | hebrew_general_ci | 1 | tis620 | TIS620 Thai | tis620_thai_ci | 1 | euckr | EUC-KR Korean | euckr_korean_ci | 2 | koi8u | KOI8-U Ukrainian | koi8u_general_ci | 1 | gb2312 | GB2312
8、 Simplified Chinese | gb2312_chinese_ci | 2 | greek | ISO 8859-7 Greek | greek_general_ci | 1 | cp1250 | Windows Central European | cp1250_general_ci | 1 | gbk | GBK Simplified Chinese | gbk_chinese_ci | 2 | latin5 | ISO 8859-9 Turkish | latin5_turkish_ci | 1 | armscii8 | ARMSCII-8 Armenian | armsci
9、i8_general_ci | 1 | utf8 | UTF-8 Unicode | utf8_general_ci | 3 | ucs2 | UCS-2 Unicode | ucs2_general_ci | 2 | cp866 | DOS Russian | cp866_general_ci | 1 | keybcs2 | DOS Kamenicky Czech-Slovak | keybcs2_general_ci | 1 | macce | Mac Central European | macce_general_ci | 1 | macroman | Mac West Europea
10、n | macroman_general_ci | 1 | cp852 | DOS Central European | cp852_general_ci | 1 | latin7 | ISO 8859-13 Baltic | latin7_general_ci | 1 | cp1251 | Windows Cyrillic | cp1251_general_ci | 1 | cp1256 | Windows Arabic | cp1256_general_ci | 1 | cp1257 | Windows Baltic | cp1257_general_ci | 1 | binary | B
11、inary pseudo charset | binary | 1 | geostd8 | GEOSTD8 Georgian | geostd8_general_ci | 1 | cp932 | SJIS for Windows Japanese | cp932_japanese_ci | 2 | eucjpms | UJIS for Windows Japanese | eucjpms_japanese_ci | 3 |+-+-+-+-+以上查看 MySQL 字符集命令,適用于 Windows & Linux。 1.查找MySQL的cnf文件的位置find / -iname '
12、;*.cnf' -print/usr/share/mysql/my-innodb-heavy-4G.cnf /usr/share/mysql/my-f/usr/share/mysql/my-f/usr/share/mysql/my-f/usr/share/mysql/my-f/usr/share/texmf/web2c/f/usr/share/texmf/web2c/f/usr/share/texmf/web2c/f/usr/share/texmf/tex/xmltex/f/usr/share/texmf/tex/jadetex/f/usr/share/doc/MySQL-server
13、-community-5.1.22/my-innodb-heavy-4G.cnf/usr/share/doc/MySQL-server-community-5.1.22/my-f/usr/share/doc/MySQL-server-community-5.1.22/my-f/usr/share/doc/MySQL-server-community-5.1.22/my-f/usr/share/doc/MySQL-server-community-5.1.22/my-f2. 拷貝 f、my-f、my-f、my-innodb-heavy-4G.cnf其中的一個到/etc下,命名為f cp /usr
14、/share/mysql/my-f /etc/f3. 修改fvi /etc/f在client下添加default-character-set=utf8在mysqld下添加default-character-set=utf84.重新啟動MySQL rootbogon # /etc/rc.d/init.d/mysql restartShutting down MySQL
15、; 確定 Starting MySQL. 確定 rootbogon # mysql
16、 -u root -pEnter password:Welcome to the MySQL monitor. Commands end with ; or g.Your MySQL connection id is 1Server version: 5.1.22-rc-community-log MySQL Community Edition (GPL)Type 'help;' or 'h' for help. Type 'c' to clear the buffer.5.查看字符集設置mysql> show variables like
17、 'collation_%'+-+-+| Variable_name | Value |+-+-+| collation_connection | utf8_general_ci | collation_database | utf8_general_ci | collation_server | utf8_general_ci
18、 |+-+-+3 rows in set (0.02 sec)mysql> show variables like 'character_set_%'+-+-+| Variable_name | Value |+-+-+| character_set_client
19、60; | utf8 | character_set_connection | utf8 | character_set_database
20、 | utf8 | character_set_filesystem | binary | character_set_results | utf8&
21、#160; | character_set_server | utf8 | character_set_system
22、0; | utf8 | character_sets_dir | /usr/share/mysql/charsets/ |+-+-+8 rows in set (0.02 sec)mysql>其他的一些設置方法: 修改數(shù)據庫的字符集 mysql>use mydbmysql>alter da
23、tabase mydb character set utf-8;創(chuàng)建數(shù)據庫指定數(shù)據庫的字符集mysql>create database mydb character set utf-8;通過配置文件修改: 修改/var/lib/mysql/mydb/db.optdefault-character-set=latin1default-collation=latin1_swedish_ci為default-character-set=utf8default-collation=utf8_general_ci重起MySQL:rootbogon # /etc/rc.d/init.d/mysql
24、restart通過MySQL命令行修改: mysql> set character_set_client=utf8;Query OK, 0 rows affected (0.00 sec)mysql> set character_set_connection=utf8;Query OK, 0 rows affected (0.00 sec)mysql> set character_set_database=utf8;Query OK, 0 rows affected (0.00 sec)mysql> set character_set_results=utf8;Quer
25、y OK, 0 rows affected (0.00 sec)mysql> set character_set_server=utf8;Query OK, 0 rows affected (0.00 sec)mysql> set character_set_system=utf8;Query OK, 0 rows affected (0.01 sec)mysql> set collation_connection=utf8;Query OK, 0 rows affected (0.01 sec)mysql> set collation_database=utf8;Qu
26、ery OK, 0 rows affected (0.01 sec)mysql> set collation_server=utf8;Query OK, 0 rows affected (0.01 sec)查看:mysql> show variables like 'character_set_%'+-+-+| Variable_name | Value
27、0; |+-+-+| character_set_client | utf8 | character_set_connection | utf8
28、0; | character_set_database | utf8 | character_set_filesystem | binary | character_set
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
- 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2024貨物賒欠買賣合同樣本范文
- 物業(yè)保潔承包合同
- 個人借款合同參考
- 2024不可撤銷居間合同
- 2024年商業(yè)用途日照房屋租賃合同
- 建筑安裝分包合同
- 2024的廠房轉讓合同范文
- 2024承包施工合同范文
- 2024車輛承包經營合同書雇用車輛合同書
- 2024標準版商務咨詢服務合同模板
- 第十二章-車船稅
- GB/T 4706.114-2024家用和類似用途電器的安全第114部分:飲用水處理裝置的特殊要求
- 第一、二單元復習課件 2024-2025學年統(tǒng)編版七年級歷史上冊
- 外包司機合同范本
- 2.2.2 脊椎動物-魚(第1課時)課件-2024-2025學年人教版生物七年級上冊
- 食品加工機械 食材凈化清洗設備 編制說明
- 2024中國鐵塔集團湖南分公司招聘24人高頻考題難、易錯點模擬試題(共500題)附帶答案詳解
- (高清版)JT∕T 1402-2022 交通運輸行政執(zhí)法基礎裝備配備及技術要求
- 中華聯(lián)合保險集團股份有限公司行測筆試題庫2024
- 印刷服務 投標方案(技術方案)
- 必修一《數(shù)據與計算》復習提綱與練習題
評論
0/150
提交評論