Import the csv file to the mysql database bitsCN.com.
The unified encoding method is UTF-8, and the csv file encoding method is set to UTF-8.
Create a new table in the database. the column attributes must be consistent with the csv file. set ** month ** to date format in csv, instead of string, in this way, you can import time and so on.
Set the time column as the selected time column, right-click the table attribute, and set it to date.
LOAD DATA INFILE "**.csv" INTO TABLE XX CHARACTER SET utf8 FIELDS TERMINATED BY "," ;
The load data format is as follows:
Load data [LOW_PRIORITY] [LOCAL] INFILE 'file_name.txt '[REPLACE | IGNORE]
Into table tbl_name
[FIELDS
[Terminated by '/t']
[OPTIONALLY] enclosed by '']
[Escaped by '//']
[Lines terminated by '/N']
[IGNORE number LINES]
[(Col_name,...)]
Where,
LOW_PRIORITY
If you specify this keyword, the execution of the load data statement will be delayed until no other client is reading the table.
LOCAL
If the LOCAL keyword is specified, it will explain the connected client:
? If LOCAL is specified, the client component on the client host reads the file and sends it to the server. You can provide the complete path of the file to determine its exact location. If the relative path is given, the file name is relative to the directory where the client component was started.
? If LOCAL is not specified, the file is located on the server host and is directly read by the server.
When files are located from the server host, the server uses the following rules:
? If a complete path is specified, the server uses this path name.
? If the relative path of one or more front components is specified, the server searches for files in a directory relative to the server.
? If a file name without a front component is specified, the server searches for files from the Database Directory of the current database.
-- Character set: mysql character set, which is used to explain the information in the file
-- Into table: TABLE to which the data is imported
-- Fields terminated by: used as a delimiter
-- Enclosed by: What is surrounded (required for output)
Csv, short for Comma Separated Value (Comma-Separated values), is usually a plain text file. The data in it is separated BY, so fields terminated ","
BitsCN.com