Created
July 11, 2024 02:25
-
-
Save ricardogranafirst/cd0b1428bdfde4151beed5d9fc5f2335 to your computer and use it in GitHub Desktop.
Carregar arquivo grande para o MySQL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* crie a tabela para receber os dados. Pode usar a tabela tse2018am (zerar antes) ou copiar sua estrutura para uma nova tabela | |
* converter arquivo para latin1: | |
iconv -f ISO-8859-1 -t UTF-8 /var/lib/mysql-files/tse.csv -o /var/lib/mysql-files/tse_utf8.csv | |
* copiar para Docker (se preciso): | |
docker cp tse_utf8.csv lhince-db:/var/lib/mysql-files/tse_utf8.csv | |
* Fazer login no mysql e carregar o csv para a tabela com o comando abaixo | |
LOAD DATA INFILE '/var/lib/mysql-files/tse_utf8.csv' | |
IGNORE INTO TABLE tse2020am2t <---- nome da tabela aqui | |
FIELDS TERMINATED BY ',' | |
OPTIONALLY ENCLOSED BY '"' | |
ESCAPED BY '"' | |
LINES TERMINATED BY '\n' | |
IGNORE 1 LINES; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment