MySQL Chinese string encoding processing and R language batch inserting data into the database

The database supports Chinese characters

1. Enter the database mysql -u root -p ****

2. View all coded characters show variables like'%char%';

There are two places to pay attention to here: character_set_client and character_set connection, these two places must be gbk;

3. Modify mysq to the normal encoding method

mysql>set character_set_client=gbk;

mysql>set character_set_connection=gbk;

mysql>set character_set_database=gbk;

mysql>set character_set_server=gbk;
set character_set_server=gbk;

Remember: the mysql client (client) encoding must be "gbk"; otherwise it will cause "mysql cannot insert Chinese; if your mysql Chinese garbled, the solution is similar to this article, the principle is still the same;

Reference: https://www.cnblogs.com/showcase/p/12095725.html

R language batch inserts mysql data,

Reference materials:
http://www.imooc.com/wenda/detail/573872
https://www.jianshu.com/p/7dc693b78066

Novices who connect to MySQL database in R often encounter local_infile .local(conn, statement, …): could not run statement: The use error. This is caused by the fact that files are not allowed to be written in the database settings. You can get the following by consulting the information Solution: set local_infile = 1 in mysql. This setting should be set again after each restart. If you want to change this setting permanently, you can use set persist local_infile = 1

I solved this problem on MySQL 8.0.11 using the MySQL terminal command:

SET GLOBAL local_infile = true;
I mean, my first login is the same as usual:

After mysql -u user -p*
, you can use the following command to check the status:

SHOW GLOBAL VARIABLES LIKE'local_infile';
should be open. Here, I will not write articles about the security issued when loading local files into the database.

Guess you like

Origin blog.csdn.net/tandelin/article/details/106589765