Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

16.8K
Visualizações
ERROR 2068 (HY000): LOAD DATA LOCAL INFILE file request rejected due to restrictions on access

comment I'm trying ,

mysql> 

LOAD DATA LOCAL INFILE '/var/tmp/countries.csv' 
INTO TABLE countries 
FIELDS TERMINATED BY ',' 
ENCLOSED BY '"' LINES 
TERMINATED BY '\n' 
IGNORE 1 LINES 
(CountryId,CountryCode,CountryDescription,CountryRegion,LastUpdatedDate,created_by,created_on)
SET created_by = 'DH_INITIAL_LOAD', created_on = current_timestamp();

ERROR 2068 (HY000): LOAD DATA LOCAL INFILE file request rejected due to restrictions on access.`

It was working fine, I downloaded pymysql and mysql connector for the python script. I uninstalled and checked still it is not working. The verion and infile is ON,

 select version() -| 8.0.17



mysql> SHOW GLOBAL VARIABLES LIKE 'local_infile';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| local_infile  | ON    |
+---------------+-------+
1 row in set (0.00 sec)
over 4 years ago · Santiago Trujillo
7 Respostas
Responde à pergunta

0

on windows :
for me after enabling local in both client and server and settings (in my.ini)

        [client]
          local_infile=1
        [mysqld]
          secure_file_priv=""

 the sql command ...
   load data local infile "FILE" 
 change to 
    load data infile "FILE"

works every time ...
so much so I do not even use the load local anymore and am not sure of the point of the command ...  
over 4 years ago · Santiago Trujillo Relatório

0

For Mac users, if the above solutions don't work (and I am using mac OS Big Sur)

Go to the terminal and type

$ vi ~/.my.cnf

Then add this to the file

[mysqld]
secure_file_priv = ''

Save and exit the window. Now go to terminal and restart mysql server using

$mysql.server restart

enter mysql server using

$ mysql -u <your username> -p

Now enter the following in mysql

mysql> SHOW VARIABLES LIKE "secure_file_priv";

This should show the value of the variable as blank. Now if you use the query

load data local infile '<complete_file_path>' 
into table <table_name>
fields terminated by ',';

This should work! also make sure you have set the following variable to "ON" using:

set global local_infile = 1;

Update

For windows user - having mysql 8.0 installed following is the secure file variable mentioned above

secure-file-priv="C:/ProgramData/MySQL/MySQL Server 8.0/Uploads"
over 4 years ago · Santiago Trujillo Relatório

0

To Fix this error (mysql 8):

ERROR 2068 (HY000): LOAD DATA LOCAL INFILE file request rejected due to restrictions on access.

add the following line into your server's config file, under the "client" section:

[client]
loose-local-infile=1

That will fix the error. However, this assumes you have already set the following under the "mysqld" section:

[mysqld]
local_infile=1

Having both parameters set in your config file will allow loading data from any directory.

Here's a simple example of use. Run in the mysql terminal:

load data local infile '/path/to/file/data.tsv' into table my_table_name
 fields terminated by '\t'
 LINES TERMINATED BY  '\n'
(
 `col1`,
 `col2`,
 `col3`,
 `col4`
);
over 4 years ago · Santiago Trujillo Relatório

0

For ubuntu:

  1. edit the file /etc/mysql/mysql.conf.d/mysqld.cnf and add the following line at the end:

    # secure_file_priv=""

  2. Restart the service

     systemctl stop mysql 
     systemctl start mysql
    
  3. run: mysql -u root -p and check the local infile variable

      mysql> show global variables like 'local_infile';
    
      +---------------+-------+ 
      | Variable_name | Value |
      +---------------+-------+
      | local_infile  | OFF   |
      +---------------+-------+
      1 row in set (0.00 sec)
    
  4.   mysql> set global local_infile=true;
    
      +---------------+-------+ 
      | Variable_name | Value |
      +---------------+-------+
      | local_infile  | ON    |
      +---------------+-------+
      1 row in set (0.00 sec)
    
  5.   mysql> exit
      Bye
    
  1. run

     mysql --local-infile=1 -u root -p
    
  2.   LOAD DATA INFILE '/var/lib/mysql-files/filename' INTO TABLE tablename;
    
over 4 years ago · Santiago Trujillo Relatório

0

Using MySql Workbench 8 or above introduced this issue. This fixed it for me:

This restriction can be removed from MySQL Workbench 8.0 in the following way. Edit the connection, on the Connection tab, go to the 'Advanced' sub-tab, and in the 'Others:' box add the line 'OPT_LOCAL_INFILE=1'.

This should allow a client using the Workbench to run LOAD DATA INFILE as usual.

Quoted from this link: https://bugs.mysql.com/bug.php?id=91872

over 4 years ago · Santiago Trujillo Relatório

0

Known issue: https://bugs.mysql.com/bug.php?id=91872

for workaround when trying to connect to mysql in itself set local-infile to 1 and perform the load command: mysql --local-infile=1 -h$MASTER_DB_HOST -u$MASTER_DB_USER -p$MASTER_DB_PASSWD -D$MASTER_DB_NAME

over 4 years ago · Santiago Trujillo Relatório

0

Having local_infile set to ON on the server isn't always enough. Since MySQL 8.0, the client must also explicitly allow LOCAL INFILE ; otherwise, you'll get error 2068.

If you are using the mysql client, try connecting like this:

 mysql --local-infile=1 -u usuario -p

And verify:

 SHOW SESSION VARIABLES LIKE 'local_infile';

If the problem started after installing or updating connectors (such as PyMySQL or MySQL Connector), the client might be disabling LOCAL INFILE for security reasons. In that case, you need to enable it in the connection settings, for example:

 mysql.connector.connect(
 ...,
 allow_local_infile=True
)

or the equivalent for the connector you are using.

In summary: the server already has local_infile=ON , but the client or connector executing the query probably does not have LOCAL INFILE enabled.

3 months ago · Ruben Alexander Serrano Porras Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda