The Error Code: 2068. LOAD DATA LOCAL INFILE file request rejected due to restrictions on access error occurs when MySQL rejects the LOAD DATA LOCAL INFILE command due to security restrictions. This can happen for various reasons, including server-side and client-side configurations.

Error:

Error Code: 2068. LOAD DATA LOCAL INFILE file request rejected due to restrictions on access.

Steps to Resolve the Error

1. Enable local_infile on the Server

Make sure the MySQL server is configured to allow local file loading by setting the local_infile system variable.

Option 1: Add to Configuration File (my.cnf or my.ini)

[mysqld]
local_infile=1

Option 2: Set Dynamically

SET GLOBAL local_infile = 1;

2. Enable local_infile on the Client

Using MySQL Command Line Client

When starting the MySQL client from the command line, use the –local-infile option:

mysql --local-infile -u your_user -p

Using MySQL Workbench

If local_infile is enabled and still getting errors, you might need to enable opt_local_file.

In the Database dropdown menu, click Manage Connections. 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‘.

error code 2068 mysql workbench connection tab others box opt_local_infile=1

Additional Considerations

  • Ensure that the file path is correct and accessible from the client machine.
  • Ensure the MySQL user has the necessary permissions to load data into the target table.
  • Verify that the file format matches the specifications in your LOAD DATA LOCAL INFILE statement.

For more information, please contact us.