MySQL: Import from CSV

Today I had to import some data from a CSV file into a table on a MySQL server.
So here is how to do it:

LOAD DATA LOCAL INFILE '/importfile.csv' 
INTO TABLE test_table 
FIELDS TERMINATED BY ',' 
LINES TERMINATED BY '\n' 
(field1, filed2, field3);

Source

Of course, you will need to have access to the machine where the database is running. As an alternative, I am sure there are developer tools that can enter the data remotely.

Hello world

My name is Simon Krenger, I am a Technical Account Manager (TAM) at Red Hat. I advise our customers in using Kubernetes, Containers, Linux and Open Source.

Elsewhere

  1. GitHub
  2. LinkedIn
  3. GitLab