is there a way to run a remote shell script on AWS MySql/Aurora that references sql remote files












0















I am trying to run an init script on a AWS MySQL database, I have been able to run the same script on a local instance of MySQL but not when attempting it on a remote instance. This is the command I run, from the directory that has both the shell script and sql resource files:




mysql -u user -p -h endpoint123.us-east-1.rds.amazonaws.com -P 3306 <
create_database.sh




And after entering in my password get the following error:




ERROR 1064 (42000) at line 15: You have an error in your SQL syntax;
check the manual that corresponds to your MySQL server version for the
right syntax to use near [line referencing SQL files]




Basically the script references local sql files that are also needed for the setup to complete. As far as I know, it is not possible to copy these files over to the AWS RDS machine. Is there any way to solve this so the shell script can run properly? Either by copying the files over or by running the shell script remotely? Thanks in advance!










share|improve this question


















  • 1





    It looks like you're trying to use the shell script as input to the mysql client. The mysql client can't parse shell scripts, it only understands .sql files. I would guess you need to modify your shell script to execute against the remote Aurora instance. I expect the shell script to run mysql, and it needs your -h option to specify a remote instance.

    – Bill Karwin
    Jan 2 at 17:24











  • can you post the summary of what you are exactly trying to achieve here, cause mysql client only understand sql files

    – varnit
    Jan 2 at 18:21











  • I now realize what I'm trying to do is needing to pipe the sql scripts that the shell script references into the mysql table

    – user2394523
    Jan 2 at 19:39
















0















I am trying to run an init script on a AWS MySQL database, I have been able to run the same script on a local instance of MySQL but not when attempting it on a remote instance. This is the command I run, from the directory that has both the shell script and sql resource files:




mysql -u user -p -h endpoint123.us-east-1.rds.amazonaws.com -P 3306 <
create_database.sh




And after entering in my password get the following error:




ERROR 1064 (42000) at line 15: You have an error in your SQL syntax;
check the manual that corresponds to your MySQL server version for the
right syntax to use near [line referencing SQL files]




Basically the script references local sql files that are also needed for the setup to complete. As far as I know, it is not possible to copy these files over to the AWS RDS machine. Is there any way to solve this so the shell script can run properly? Either by copying the files over or by running the shell script remotely? Thanks in advance!










share|improve this question


















  • 1





    It looks like you're trying to use the shell script as input to the mysql client. The mysql client can't parse shell scripts, it only understands .sql files. I would guess you need to modify your shell script to execute against the remote Aurora instance. I expect the shell script to run mysql, and it needs your -h option to specify a remote instance.

    – Bill Karwin
    Jan 2 at 17:24











  • can you post the summary of what you are exactly trying to achieve here, cause mysql client only understand sql files

    – varnit
    Jan 2 at 18:21











  • I now realize what I'm trying to do is needing to pipe the sql scripts that the shell script references into the mysql table

    – user2394523
    Jan 2 at 19:39














0












0








0








I am trying to run an init script on a AWS MySQL database, I have been able to run the same script on a local instance of MySQL but not when attempting it on a remote instance. This is the command I run, from the directory that has both the shell script and sql resource files:




mysql -u user -p -h endpoint123.us-east-1.rds.amazonaws.com -P 3306 <
create_database.sh




And after entering in my password get the following error:




ERROR 1064 (42000) at line 15: You have an error in your SQL syntax;
check the manual that corresponds to your MySQL server version for the
right syntax to use near [line referencing SQL files]




Basically the script references local sql files that are also needed for the setup to complete. As far as I know, it is not possible to copy these files over to the AWS RDS machine. Is there any way to solve this so the shell script can run properly? Either by copying the files over or by running the shell script remotely? Thanks in advance!










share|improve this question














I am trying to run an init script on a AWS MySQL database, I have been able to run the same script on a local instance of MySQL but not when attempting it on a remote instance. This is the command I run, from the directory that has both the shell script and sql resource files:




mysql -u user -p -h endpoint123.us-east-1.rds.amazonaws.com -P 3306 <
create_database.sh




And after entering in my password get the following error:




ERROR 1064 (42000) at line 15: You have an error in your SQL syntax;
check the manual that corresponds to your MySQL server version for the
right syntax to use near [line referencing SQL files]




Basically the script references local sql files that are also needed for the setup to complete. As far as I know, it is not possible to copy these files over to the AWS RDS machine. Is there any way to solve this so the shell script can run properly? Either by copying the files over or by running the shell script remotely? Thanks in advance!







mysql amazon-web-services shell amazon-rds amazon-rds-aurora






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jan 2 at 16:59









user2394523user2394523

302




302








  • 1





    It looks like you're trying to use the shell script as input to the mysql client. The mysql client can't parse shell scripts, it only understands .sql files. I would guess you need to modify your shell script to execute against the remote Aurora instance. I expect the shell script to run mysql, and it needs your -h option to specify a remote instance.

    – Bill Karwin
    Jan 2 at 17:24











  • can you post the summary of what you are exactly trying to achieve here, cause mysql client only understand sql files

    – varnit
    Jan 2 at 18:21











  • I now realize what I'm trying to do is needing to pipe the sql scripts that the shell script references into the mysql table

    – user2394523
    Jan 2 at 19:39














  • 1





    It looks like you're trying to use the shell script as input to the mysql client. The mysql client can't parse shell scripts, it only understands .sql files. I would guess you need to modify your shell script to execute against the remote Aurora instance. I expect the shell script to run mysql, and it needs your -h option to specify a remote instance.

    – Bill Karwin
    Jan 2 at 17:24











  • can you post the summary of what you are exactly trying to achieve here, cause mysql client only understand sql files

    – varnit
    Jan 2 at 18:21











  • I now realize what I'm trying to do is needing to pipe the sql scripts that the shell script references into the mysql table

    – user2394523
    Jan 2 at 19:39








1




1





It looks like you're trying to use the shell script as input to the mysql client. The mysql client can't parse shell scripts, it only understands .sql files. I would guess you need to modify your shell script to execute against the remote Aurora instance. I expect the shell script to run mysql, and it needs your -h option to specify a remote instance.

– Bill Karwin
Jan 2 at 17:24





It looks like you're trying to use the shell script as input to the mysql client. The mysql client can't parse shell scripts, it only understands .sql files. I would guess you need to modify your shell script to execute against the remote Aurora instance. I expect the shell script to run mysql, and it needs your -h option to specify a remote instance.

– Bill Karwin
Jan 2 at 17:24













can you post the summary of what you are exactly trying to achieve here, cause mysql client only understand sql files

– varnit
Jan 2 at 18:21





can you post the summary of what you are exactly trying to achieve here, cause mysql client only understand sql files

– varnit
Jan 2 at 18:21













I now realize what I'm trying to do is needing to pipe the sql scripts that the shell script references into the mysql table

– user2394523
Jan 2 at 19:39





I now realize what I'm trying to do is needing to pipe the sql scripts that the shell script references into the mysql table

– user2394523
Jan 2 at 19:39












1 Answer
1






active

oldest

votes


















0














It looks like you want to feed in the output of your shell script to mysql. The syntax you are using is for executing a mysql (sql) script and NOT the output of a shell script. You would need to do something like this:



./script.sh | mysql -u abc -p -e


OR, in two phases:



./script.sh > out.sql  // To verify that the generated statements are correct
mysql -u abc -p -e < sql





share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54010270%2fis-there-a-way-to-run-a-remote-shell-script-on-aws-mysql-aurora-that-references%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    It looks like you want to feed in the output of your shell script to mysql. The syntax you are using is for executing a mysql (sql) script and NOT the output of a shell script. You would need to do something like this:



    ./script.sh | mysql -u abc -p -e


    OR, in two phases:



    ./script.sh > out.sql  // To verify that the generated statements are correct
    mysql -u abc -p -e < sql





    share|improve this answer




























      0














      It looks like you want to feed in the output of your shell script to mysql. The syntax you are using is for executing a mysql (sql) script and NOT the output of a shell script. You would need to do something like this:



      ./script.sh | mysql -u abc -p -e


      OR, in two phases:



      ./script.sh > out.sql  // To verify that the generated statements are correct
      mysql -u abc -p -e < sql





      share|improve this answer


























        0












        0








        0







        It looks like you want to feed in the output of your shell script to mysql. The syntax you are using is for executing a mysql (sql) script and NOT the output of a shell script. You would need to do something like this:



        ./script.sh | mysql -u abc -p -e


        OR, in two phases:



        ./script.sh > out.sql  // To verify that the generated statements are correct
        mysql -u abc -p -e < sql





        share|improve this answer













        It looks like you want to feed in the output of your shell script to mysql. The syntax you are using is for executing a mysql (sql) script and NOT the output of a shell script. You would need to do something like this:



        ./script.sh | mysql -u abc -p -e


        OR, in two phases:



        ./script.sh > out.sql  // To verify that the generated statements are correct
        mysql -u abc -p -e < sql






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Feb 5 at 19:25









        Karthik RajanKarthik Rajan

        581316




        581316
































            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54010270%2fis-there-a-way-to-run-a-remote-shell-script-on-aws-mysql-aurora-that-references%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Angular Downloading a file using contenturl with Basic Authentication

            Olmecas

            Can't read property showImagePicker of undefined in react native iOS