mysql亂碼問題
原文:http://www.jb51.net/article/31181.htm
我在navicat中的測試:
mysql> use code; Database changed mysql> set names `utf8`; Query OK, 0 rows affected mysql> select * from t2; +--------------+ | test | +--------------+ | 測試utf8 | | 阿薩斯 | | 測試sdsdsgbk | +--------------+ 3 rows in set mysql> insert into t2 values(`cat不不不utf8`); Query OK, 1 row affected mysql> select * from t2; +---------------+ | test | +---------------+ | 測試utf8 | | 阿薩斯 | | 測試sdsdsgbk | | cat不不不utf8 | +---------------+ 4 rows in set mysql> set names `gbk `; Query OK, 0 rows affected mysql> insert into t2 values(`cat不不不gbk `); Query OK, 1 row affected mysql> select * from t2; +---------------+ | test | +---------------+ | ����utf8 | | ����˹ | | ����sdsdsgbk | | cat������utf8 | | cat不不不gbk | +---------------+ 5 rows in set mysql> set names `utf8`; Query OK, 0 rows affected mysql> select * from t2; +-----------------+ | test | +-----------------+ | 測試utf8 | | 阿薩斯 | | 測試sdsdsgbk | | cat不不不utf8 | | cat涓嶄笉涓峠bk | +-----------------+ 5 rows in set mysql> select * from t2; +-----------------+ | test | +-----------------+ | 測試utf8 | | 阿薩斯 | | 測試sdsdsgbk | | cat不不不utf8 | | cat涓嶄笉涓峠bk | | cmd積極gbk | +-----------------+ 6 rows in set mysql> show variables like `character%`; +--------------------------+---------------------------------------------------------------+ | Variable_name | Value | +--------------------------+---------------------------------------------------------------+ | character_set_client | utf8 | | character_set_connection | utf8 | | character_set_database | utf8 | | character_set_filesystem | binary | | character_set_results | utf8 | | character_set_server | utf8 | | character_set_system | utf8 | | character_sets_dir | D:Program Files (x86)MySQLMySQL Server 5.0sharecharsets | +--------------------------+---------------------------------------------------------------+ 8 rows in set mysql>
在cmd中的測試:
mysql> set names `utf8`; Query OK, 0 rows affected (0.00 sec) mysql> insert into t2 values(`測試sdsdsutf8`); ERROR 1406 (22001): Data too long for column `test` at row 1 mysql> set names `gbk`; Query OK, 0 rows affected (0.00 sec) mysql> insert into t2 values(`測試sdsdsgbk`); Query OK, 1 row affected (0.32 sec) mysql> select * from t2; +--------------+ | test | +--------------+ | 測試utf8 | | 阿薩斯 | | 測試sdsdsgbk | +--------------+ 3 rows in set (0.00 sec) mysql> select * from t2; +-----------------+ | test | +-----------------+ | 測試utf8 | | 阿薩斯 | | 測試sdsdsgbk | | cat不不不utf8 | | cat涓嶄笉涓峠bk | +-----------------+ 5 rows in set (0.00 sec) mysql> set names `gbk`; Query OK, 0 rows affected (0.00 sec) mysql> select * from t2; +-----------------+ | test | +-----------------+ | 測試utf8 | | 阿薩斯 | | 測試sdsdsgbk | | cat不不不utf8 | | cat涓嶄笉涓峠bk | +-----------------+ 5 rows in set (0.00 sec) mysql> set names `utf8`; Query OK, 0 rows affected (0.00 sec) mysql> select * from t2; +----------------------+ | test | +----------------------+ | 嫻嬭瘯utf8 | | 闃胯惃鏂? | | 嫻嬭瘯sdsdsgbk | | cat涓嶄笉涓島tf8 | | cat娑撳秳絎夋稉宄燽k | +----------------------+ 5 rows in set (0.00 sec) mysql> set names `utf8`; Query OK, 0 rows affected (0.00 sec) mysql> select * from t2; +----------------------+ | test | +----------------------+ | 嫻嬭瘯utf8 | | 闃胯惃鏂? | | 嫻嬭瘯sdsdsgbk | | cat涓嶄笉涓島tf8 | | cat娑撳秳絎夋稉宄燽k | +----------------------+ 5 rows in set (0.00 sec) mysql> insert into t2 values(`cmd積極utf8`); ERROR 1406 (22001): Data too long for column `test` at row 1 mysql> insert into t2 values(`cmd積極utf8`); ERROR 1406 (22001): Data too long for column `test` at row 1 mysql> set names `gbk`; Query OK, 0 rows affected (0.00 sec) mysql> insert into t2 values(`cmd積極gbk`); Query OK, 1 row affected (0.05 sec) mysql> select * from t2; +-----------------+ | test | +-----------------+ | 測試utf8 | | 阿薩斯 | | 測試sdsdsgbk | | cat不不不utf8 | | cat涓嶄笉涓峠bk | | cmd積極gbk | +-----------------+ 6 rows in set (0.00 sec) mysql> show variables like `charcate%`; Empty set (0.00 sec) mysql> show variables like `character%`; +--------------------------+---------------------------------------------------------------+ | Variable_name | Value | +--------------------------+---------------------------------------------------------------+ | character_set_client | gbk | | character_set_connection | gbk | | character_set_database | utf8 | | character_set_filesystem | binary | | character_set_results | gbk | | character_set_server | utf8 | | character_set_system | utf8 | | character_sets_dir | D:Program Files (x86)MySQLMySQL Server 5.0sharecharsets | +--------------------------+---------------------------------------------------------------+ 8 rows in set (0.00 sec) mysql>
相關文章
- MySql中文亂碼問題解決MySql
- MySQL:亂碼問題處理流程MySql
- mysql亂碼的問題如何解決MySql
- python查詢mysql中文亂碼問題PythonMySql
- pdo_mysql 資料庫亂碼問題MySql資料庫
- MySql用Windows命令列中亂碼問題MySqlWindows命令列
- MySQL亂碼問題(為什麼?追根溯源)MySql
- mysql使用source 命令亂碼問題解決方法MySql
- mysql資料庫concat拼接字串亂碼問題MySql資料庫字串
- confluence亂碼問題
- Mysql中文亂碼問題的最佳解決方法MySql
- vscode中文亂碼問題VSCode
- EasyUI 中文亂碼問題UI
- mysql5.7.22設定中文編碼-解決亂碼問題LinuxMySqlLinux
- Python爬蟲亂碼問題Python爬蟲
- 解決中文亂碼問題
- Kali Linux 2020.1亂碼問題Linux
- jasperreport HTML格式亂碼問題HTML
- Tomcat配置jsp亂碼問題TomcatJS
- IDEA中Tomcat亂碼問題IdeaTomcat
- Python BeautifulSoup中文亂碼問題Python
- MySQL 字符集與亂碼與collation設定的問題?MySql
- 常見php與mysql中文亂碼問題解決辦法PHPMySql
- flashfxp 亂碼,2種辦法解決flashfxp 亂碼問題
- Druid.io SQL亂碼問題UISQL
- confluence中文顯示亂碼問題
- springmvc 解決中文亂碼問題SpringMVC
- Jmeter 解決中文亂碼問題JMeter
- Gradle 編譯警告亂碼問題Gradle編譯
- Java GBK 中文亂碼問題分析Java
- Mysqldump匯出亂碼問題排查MySql
- 【日誌亂碼】解決Tomcat啟動控制檯亂碼問題Tomcat
- MySQL直接匯出CSV檔案,並解決中文亂碼的問題MySql
- 記錄PHP post提交表單匯入mysql中文亂碼的問題PHPMySql
- Java Web開發中文亂碼問題JavaWeb
- 解決Kali Linux 2020.1亂碼問題Linux
- [20200225]alert檔案亂碼問題.txt
- TongWeb下亂碼問題解決思路Web
- java中亂碼問題解決方法Java