Question

LOAD DATA local_infile=1

Hello Support Im trying to import a lot of rows into my database MySQL using DigitalOceam Databases, but i cant connect it using LOAD DATA, and I need to import a file CSV in a performant way. I dont have idea if it is possible do this using this database because seems no there a way to upload the file and then run an LOAD DATA LOCAL INFILE query insert… I cant set global local_infile=1, it is posible? Could do you help me? Thank you


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Bobby Iliev
Site Moderator
Site Moderator badge
February 21, 2024

Hey!

The available configuration options that you can change for the Managed MySQL database clusters are available here:

https://docs.digitalocean.com/reference/api/api-reference/#operation/databases_patch_config

Unfortunately local_infile is not configurable. You can try reaching out to the DigitalOcean support team who might be able to enable this for you:

https://www.digitalocean.com/support/

However, as in a managed database service, direct access to the database server’s filesystem is restricted for security and operational reasons. This means traditional methods of directly placing a file on the server and loading it into the database might not be directly applicable.

You can try using a tool like MySQL Workbench or a similar tool. As some of the database management tools offer features to import data from CSV files into your database without directly using the LOAD DATA LOCAL INFILE command.

An alternative option would be to write a small script in a language like Python, PHP, or Node.js to read the CSV file and insert rows into the database using individual INSERT statements or batch insertions. While not as fast as LOAD DATA LOCAL INFILE, that way you will have more control and can be adapted to match the managed database requirements.

Hope that helps!

- Bobby.

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Featured on Community

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel