3

So I was searching for a solution that could let me export S3 data into Aurora Serverless. I know that the LOAD DATA request is only available for the Aurora cluster not the serverless one. I've found some documentation about the data injection from S3 to RDS MySQL but I don't know if this still applies to Amazon Aurora MySQL.

Linda Naoui
  • 147
  • 13

1 Answers1

2

If you're ok with temporarily putting the data on an ec2 instance, you can do it in two steps:

aws s3 cp s3://path/to/mydatafile /local/path/to/mydatafile

mysql --defaults-file=/path/to/.my.cnf -e "load data local infile '/local/path/to/mydatafile' into table sampletable"

References

StackOverflow discussion on loading data

MySQL "load data" reference

Copying from s3

Using MySQL options files

enharmonic
  • 1,800
  • 15
  • 30
  • @Buddha yes, this works for Aurora serverless – enharmonic Feb 11 '21 at 19:42
  • Where do you place the file to load if the Aurora instance has the `secure_file_priv` parameter active? – vmaldosan Feb 18 '21 at 16:54
  • I just read this on the MySQL docs(https://dev.mysql.com/doc/refman/5.7/en/load-data.html): `When using LOCAL with LOAD DATA, a copy of the file is created in the directory where the MySQL server stores temporary files` – vmaldosan Feb 18 '21 at 17:31
  • @vmaldosan the secure_file_priv parameter does not apply to Aurora Serverless (and is not modifiable) since you don't have control of the underlying infrastructure or filesystem. – enharmonic Feb 18 '21 at 19:16
  • Yup, I realized that after I read the sentence I pasted on my second comment. The issue I'm having now when I execute it is `command not found`, probably due to the multiple lines I used on the whole command. I'll paste it tomorrow in case anyone can see what's wrong with it. – vmaldosan Feb 18 '21 at 23:40
  • I finally managed to run the command successfully. The error I was having is more bizarre than I anticipated. It turns out copy and pasting the command from my text editor to EC2 bash introduces some non-printable characters that make the command fails. It works fine after writing the whole command manually, smh... – vmaldosan Feb 19 '21 at 11:05