Home >Database >Mysql Tutorial >How to set up mysql to insert Chinese without garbled characters

How to set up mysql to insert Chinese without garbled characters

coldplay.xixi
coldplay.xixiOriginal
2020-09-27 14:30:224641browse

Mysql setting method to insert Chinese without garbled characters: first specify [set names latin1;] in the SQL file; then import through the MySQL command, the code is [[root@localhost ~]# mysql -uroot -p123456 test< ;tes].

How to set up mysql to insert Chinese without garbled characters

mysql settings method to insert Chinese without garbled characters:

Method one:

Log in to MySQL, first do set names latin1, and then update the statement or execute the SQL statement

mysql> set names latin1;
mysql> source test.sql;

Method 2:

Specify set names in the SQL file latin1;Then log in to MySQL and execute the corresponding file

[root@localhost ~]# cat test.sql 
set names latin1;
insert *****************;
mysql> source test.sql;

Method three:

Specify set names latin1;and then import through the MySQL command

[root@localhost ~]# mysql -uroot -p123456 test <test.sql

Method 4:

Achieved by specifying the character set parameter of the MySQL command--default-character-set=latin1

[root@localhost ~]# cat test.sql 
insert *****************;
[root@localhost ~]# mysql -uroot -p123456 --default-character-set=latin1 test <test.sql

More Related free learning recommendations: mysql tutorial(video)

The above is the detailed content of How to set up mysql to insert Chinese without garbled characters. 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