Home >Database >Mysql Tutorial >How to Enable LOAD DATA LOCAL INFILE in MySQL 5.5 on Ubuntu 12.04 LTS?
How to Configure MySQL 5.5 on Ubuntu 12 LTS to Allow LOAD DATA LOCAL INFILE
The LOAD DATA LOCAL INFILE feature in MySQL allows data to be loaded into a table from a file stored on the local system. To enable this feature, various settings need to be configured.
Configuring my.cnf
As stated in the MySQL 5.5 manual, both the server and the client must be configured to allow LOAD DATA LOCAL INFILE. To configure the MySQL server, add the following option to the [mysqld] section of the my.cnf file:
local-infile=1
Using the --local-infile Option
Alternatively, you can use the --local-infile option when calling the MySQL client:
mysql --local-infile -uroot -pyourpwd yourdbname
Setting the Global Variable
You can also set the global local_infile variable at runtime using this SQL query:
SET GLOBAL local_infile=ON;
Additional Configuration
Ensure that the local_infile parameter is also defined in the [mysql] section of the my.cnf file:
[mysql] local-infile=1
Security Considerations
Enabling LOAD DATA LOCAL INFILE is a security risk as it allows unauthorized users to load arbitrary files onto the server. Therefore, this feature should only be enabled when necessary.
The above is the detailed content of How to Enable LOAD DATA LOCAL INFILE in MySQL 5.5 on Ubuntu 12.04 LTS?. For more information, please follow other related articles on the PHP Chinese website!