How should I enable LOAD DATA LOCAL INFILE in my.cnf in MySQL?

MySQLMySQLi Database

We can enable it with the help of the SET command with GLOBAL. The first time, local infile will be off.

The following is the syntax.

mysql> SHOW GLOBAL VARIABLES LIKE 'local_infile';

Here is the output.

+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| local_infile  | OFF   |
+---------------+-------+
1 row in set (0.01 sec)

We can enable the local infile with the help of ON or boolean value true or numeric value 1. The following is the syntax to enable the local infile.

mysql> SET GLOBAL local_infile = 'ON';
Query OK, 0 rows affected (0.00 sec)

mysql> SET GLOBAL local_infile = 1;
Query OK, 0 rows affected (0.00 sec)

mysql> SET GLOBAL local_infile = true;
Query OK, 0 rows affected (0.00 sec)

In MySQL version 8.0.12, let us check if it is ON or not.

mysql>  SHOW GLOBAL VARIABLES LIKE 'local_infile';

The following is the output.

+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| local_infile  | ON    |
+---------------+-------+
1 row in set (0.00 sec)

After restarting MySQL, it will set local infile to ON.

raja
Published on 29-Nov-2018 06:05:28
Advertisements