Solution to 1290 error when importing file data in mysql

Solution to 1290 error when importing file data in mysql

Error scenario

Use the mysql command in cmd to add data to the student information table. Use the load data method to simply import data in batches.

Prepare text data: xueshengxinxi.txt file. Use the tab key to separate the data.

An error pops up when executing "load data infile text data path into table tab_load_data".

#load data (load data) syntax, to load data is as follows:
 1 Zhang Sannan Jiangxi 1
 2 Li Sinan Sichuan 2
 3 Wang Wunan Shanghai 1
 4 Zhao Liunu Hubei 3
 5 grandson seven daughter Hubei 3
 6 Zhou Ba Nan Hunan 1 

#Test data table create table tab_load_data (
  id int auto_increment primary key,
  name varchar(10),
  sex enum('male','female'),
  native varchar(10),
  f5 int
 ); 
Error description

Using load data to import file data always pops up an error (Error 1290.....) as follows:

ERROR 1290 (HY000): The MySQL server is running with the --secure-file-priv option so it cannot execute this statement

Solution ideas (process)

1) Since the error message indicates that the secure-file-priv option is running and the load service cannot be executed, find the configuration item in the MYSQL configuration file "my.ini".

2) Before configuration, shut down the MySQL service

3) Open my.ini, search for the keyword "secure-file-priv" and find this option, then comment out this option, save it, and start the MYSQL service

4) The result is still the same error. Description The comment has no effect. What's going on?

I executed the command "show variables like '%secure%'" and found that after I commented it out, the value of secure-file-priv was NULL, indicating that import and export were prohibited.

This means that commenting it out does not work. If you don't want to delete the configuration file entry, you have to modify the directory.

5) Modify the path, execute the command "show variables like '%secure%'" to view, and restart MYSQL.


6) Execute load data again, the execution is successful

For more complex load usage, see the MySQL manual. At this point, the problem is solved.

3. Summary

Learn from this mistake:

1) load data: You can import data from an external Notepad file into a table.

The data in this notepad is usually required to be "relatively neat", with one line of text corresponding to one line of data, and a certain character (such as tab) is used to separate the values ​​of each field in a line.

2) The secure-file-priv parameter is used to limit the effects of data import and export operations.

For example: execute the LOAD, SELECT...INTO OUTFILE statement and the LOAD_FILE() function. These operations require the file permission.

3) If the secure-file-priv parameter is set to a directory name, the MYSQL service only allows file import and export operations to be performed in this directory.

This directory must exist, the MYSQL service will not create it.

4) If the secure-file-priv parameter is NULL, the MYSQL service will prohibit import and export operations.

You may also be interested in:
  • Java uses MYSQL LOAD DATA LOCAL INFILE to import large amounts of data into MySQL
  • A case study on solving deadlock caused by load data statement in MySQL
  • Solution to the problem of line break in Load Data record in mysql
  • Usage of mysql load data infile (it took 3-5 seconds to import 40w data into mysql)
  • How to use Load data in mysql
  • mysql load data infile
  • Usage of mysql Load Data InFile
  • MySQL database Load Data multiple uses

<<:  How to start jar package and run it in the background in Linux

>>:  How to understand JavaScript modularity

Recommend

Mini Program to Implement Paging Effect

This article example shares the specific code for...

javascript to switch by clicking on the picture

Clicking to switch pictures is very common in lif...

How to solve the problem of character set when logging in to Linux

Character set error always exists locale: Cannot ...

MySQL database master-slave configuration tutorial under Windows

The detailed process of configuring the MySQL dat...

Vue global filter concepts, precautions and basic usage methods

Table of contents 1. The concept of filter 1. Cus...

Linux operation and maintenance basic swap partition and lvm management tutorial

Table of contents 1. Swap partition SWAP 1.1 Crea...

How to forget the root password in Mysql8.0.13 under Windows 10 system

1. First stop the mysql service As an administrat...

How to implement real-time polygon refraction with threejs

Table of contents Preface Step 1: Setup and front...

How to dynamically add ports to Docker without rebuilding the image

Sometimes you may need to modify or add exposed p...

Historical Linux image processing and repair solutions

The ECS cloud server created by the historical Li...

Vue uses OSS to upload pictures or attachments

Use OSS to upload pictures or attachments in vue ...

HTML n ways to achieve alternate color code sample code

This article mainly introduces the sample code of...

Detailed tutorial on deploying apollo with docker

1. Introduction I won’t go into details about apo...

How to configure mysql5.6 to support IPV6 connection in Linux environment

Introduction: This article mainly introduces how ...