search

Home  >  Q&A  >  body text

Reasons for Chinese garbled characters in MySQL database

This is the statement for creating a table in my database

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

阿神阿神2753 days ago831

reply all(7)I'll reply

  • 给我你的怀抱

    给我你的怀抱2017-05-18 10:56:52

    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

    reply
    0
  • 仅有的幸福

    仅有的幸福2017-05-18 10:56:52

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

    reply
    0
  • PHP中文网

    PHP中文网2017-05-18 10:56:52

    set names utf8;

    reply
    0
  • 習慣沉默

    習慣沉默2017-05-18 10:56:52

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

    reply
    0
  • 曾经蜡笔没有小新

    曾经蜡笔没有小新2017-05-18 10:56:52

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

    reply
    0
  • PHP中文网

    PHP中文网2017-05-18 10:56:52

    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

    reply
    0
  • ringa_lee

    ringa_lee2017-05-18 10:56:52

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

    reply
    0
  • Cancelreply