mysql encoding

show variables like 'character%';

 

 

I encountered the problem of garbled characters in MYSQL today. I searched the Internet and summarized several processing methods.

1: Change the default encoding configuration of the database, find my.ini in the MYSQL installation directory, and modify the default encoding to: default-character-set=utf8

2: When creating a database, CREATE DATABASE ms_db CHARACTER SET utf8 COLLATE utf8_general_ci;

3: Execute the script: specify the encoding format set names utf8 (note, not UTF-8) The command line under windows is gbk, so 'set names gbk;' before execution

4: If you use the external access method, determine the encoding format of the request in the connection, such as: jdbc:mysql://localhost:3306/ms_db?useUnicode=true&characterEncoding=UTF-8 (do not appear any spaces, otherwise an error occurs )

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326001375&siteId=291194637