MySQL: Enable Load Data Local Infile

How to enable mysqli.load_data_local_infile on MySQL?

Check if it is Enabled

To check whether the local infile data load feature is ON or not, we can check by logging into the mysql console first. Login to mysql root or mysql admin.

mysql> SHOW GLOBAL VARIABLES LIKE 'local_infile';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| local_infile | OFF |
+---------------+-------+
1 row in set (0.00 sec)

When queried via console, the result is OFF.

So how do I enable the load_data_local_infile feature without having to restart the MySQL service?

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

Then check again if the value is ON?

mysql> SHOW GLOBAL VARIABLES LIKE 'local_infile';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| local_infile | ON |
+---------------+-------+
1 row in set (0.00 sec)

mysql>

Congratulations! Local_infile is now ON status.

Enable Load Data Local Infile of /etc/my.cnf

If you want to enable it in terms of /etc/my.cnf then add it to the MySQL or MySQLi line depending on your needs.

[MySQLi]
mysqli.allow_local_infile = On

[MySQL]
mysql.allow_local_infile = On

Then restart MySQL..

 
systemctl restart mysql


Did you find it helpful? Yes No

Send feedback
Sorry we couldn't be helpful. Help us improve this article with your feedback.