Get the App
SLTechnology News&Howtos  ›  Database  › 

How to transfer load data from File to mysql

Shulou Source: shulou.com Published: 2022-05-31 11:34:49 10月03日 Update

This article mainly introduces how to from the file load data to mysql, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let Xiaobian take you to understand.

Mysql parsing of files: columns are separated by spaces by default, and one row corresponds to one record

The format of the content in the file is as follows:

Load data infile'dappled into table ggg test.txt'

Columns can also be separated by',', and the column delimiter can be added to the sql statement.

The format of the content in the file is as follows:

Load data infile'dVUTERTER test.txt 'into table ggg FIELDS TERMINATED BY','

Continue:

When load has a large amount of data, mysql defaults to build indexes while building load, so it will be slow. You can turn off automatic indexing before load. The sql statement is: "alter table tbname disable keys;". After that, use "alter table tbname enable keys;", and mysql will supplement the creation of lost indexes.

2014-10-16 continued:

Today in load, the following error was reported:

Looking at this error, the first thing that comes to mind is that the file does not have the execution permission, but it is still not solved after modifying the file permission. Later, it is found that the reason is that the directory where the file is located does not have the execution permission.

The default read-write directory for performing show variables like'% tmpdir%'; visible mysql is / tmp

Solution: move the files you want to load to the / tmp directory!

Load data to the table, or you can specify a column, just add the column name after the indication, eg:

LOAD DATA LOCAL INFILE 'persondata.txt' INTO TABLE persondata (col1,col2); Thank you for reading this article carefully. I hope the article "how to File load data to mysql" shared by the editor is helpful to everyone. At the same time, I also hope you can support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Tags: File data article permission directory index content time format statement error such as figure line value interest delimiter method reason just at the same time Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology Redmi Shulou Information NVidia Docker