Reasons for Chinese garbled characters in MySQL database
阿神
阿神 2017-05-18 10:54:52
0
7
791

This is the statement for creating a table in my database

This is a garbled picture of my database query. What is the reason?

阿神
阿神

闭关修行中......

reply all(7)
给我你的怀抱

Assume you are using Windows command line. The default encoding of the Windows command line is GBK, and the content stored in MySQL is encoded in UTF-8, so it will be garbled when displayed.

List 3 solutions:

  • Specify the encoding for connecting to MySQL:

> mysql.exe -uroot -p --default-character-set=gbk
  • Specify the MySQL encoding after connecting:

mysql> set names gbk;
  • Modify Windows command line character encoding to UTF-8:

> chcp 65001
仅有的幸福

Look at what the sorting rules were when you created the database. Set it to this and try it utf8_general_ci

洪涛

set names utf8;

習慣沉默

Unify the encoding rules of the database to utf-8 and it should be fine

曾经蜡笔没有小新

First check whether the encoding format of your database is utf-8, if not, change it to utf-8

洪涛

Let me ask, is your terminal a terminal under Linux or a command line under Windows? The default under Windows is GBK, which is of course gibberish

左手右手慢动作

The Linux system you are using does not support Chinese. . . Just set it up to support Chinese. . .

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!