Skip to content

Instantly share code, notes, and snippets.

@GloryAlex
Created June 26, 2021 14:17
Show Gist options
  • Save GloryAlex/4e489f477c8b3024dbc8fc369a36a930 to your computer and use it in GitHub Desktop.
Save GloryAlex/4e489f477c8b3024dbc8fc369a36a930 to your computer and use it in GitHub Desktop.

首先要连接数据库:

mysql --local-infile -u root -p DATABASE

这里要注意加上关键词 --local-infile,否则会报 Loading local data is disabled 错误。 然后使用指令

  LOAD DATA infile '/src/test.csv' --CSV文件存放路径
  INTO TABLE student--要将数据导入的表名
  FIELDS TERMINATED BY ',' 
  OPTIONALLY ENCLOSED BY '"' ESCAPED BY '"' --可以没有
  LINES TERMINATED BY '\r\n'; --可以没有

具体导入设置项视导入的文件而定。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment