ERROR 2068 (HY000): LOAD DATA LOCAL INFILE file request rejected due to restrictions on access
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
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
For ubuntu:
edit the file /etc/mysql/mysql.conf.d/mysqld.cnf and add the following line at the end:
# secure_file_priv=""
Restart the service
systemctl stop mysql systemctl start mysql
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)
-
mysql> set global local_infile=true; +---------------+-------+ | Variable_name | Value | +---------------+-------+ | local_infile | ON | +---------------+-------+ 1 row in set (0.00 sec)
-
mysql> exit Bye
run
mysql --local-infile=1 -u root -p
-
LOAD DATA INFILE '/var/lib/mysql-files/filename' INTO TABLE tablename;