Home >Database >Mysql Tutorial >How to set the mysql encoding format on the command line?

How to set the mysql encoding format on the command line?

青灯夜游
青灯夜游Original
2020-09-30 14:56:505473browse

How to set the mysql encoding format on the command line: 1. Log in to mysql on the command line and enter the mysql command line editing mode; 2. Use the SET command to set the mysql encoding format, the syntax is "set character_set_..=utf8 ".

How to set the mysql encoding format on the command line?

Problem description: When using JDBC to insert data into mysql, the Chinese characters are garbled (Chinese characters are displayed with ?)

Solution: eclipse and each java file and encoding in eclipse must be consistent with the mysql database and set to utf8. Note: It is not enough to set mysql to utf-8 when installing and creating tables

1. Log in to mysql

How to set the mysql encoding format on the command line?

Enter the bin directory under the mysql installation path from the command line and enter the mysql command line editing mode

##2. SHOW VARIABLES LIKE 'character_set_%' to view various encoding formats

3. Use the SET command to change the formats that are not utf-8 to utf-8 in sequence;

set character_set_client=utf8; //Set the client encoding to utf8

set character_set_connection=utf8; //

set character_set_database=utf8; //

set character_set_results=utf8; //

set character_set_server=utf8; //

set character_set_system=utf8; //


4、SHOW VARIABLES LIKE 'character_set_%'; Check again and confirm.

How to set the mysql encoding format on the command line?

5. Finally exit; Complete

(Recommended tutorial:

mysql video tutorial )

The above is the detailed content of How to set the mysql encoding format on the command line?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn