Can we import SQL from S3 bucket to AWS ec2 (instance)?

前端 未结 3 712
傲寒
傲寒 2021-01-25 12:47

I\'m trying to import a SQL file from S3 bucket to EC2 instance.

The SQL file is publicly accessible and with the help of mysql client installed in the instance I\'m ex

相关标签:
3条回答
  • 2021-01-25 13:13

    You can't reliably do this in one step. You have to download the file, then load the local (downloaded) copy into MySQL.

    $ wget https://s3-ap-southeast-1.amazonaws.com/{sql-file} -O some-local-filename.sql
    
    $ mysql [options]
    
    mysql> source some-local-filename.sql
    
    0 讨论(0)
  • 2021-01-25 13:18

    What about not downloading the file, but directly pushing into the MySQL DB ?

    aws s3 cp s3://'<bucket name>'/'<database name>'.sql.gz - | gunzip | mysql
        --host=127.0.0.1 \
        --user='<user name>' \
        --password='<password>' \
        --port=3306
    

    or,

    aws s3 cp s3://'<bucket name>'/'<database name>'.sql - | mysql
        --host=127.0.0.1 \
        --user='<user name>' \
        --password='<password>' \
        --port=3306
    
    0 讨论(0)
  • 2021-01-25 13:24

    There is a long procedure to do so, The best details are given by AWS themself. Please read

    http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/SQLServer.Procedural.Importing.html

    0 讨论(0)
提交回复
热议问题