trouble with mysql source command

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ted clarke
    New Member
    • Nov 2008
    • 3

    trouble with mysql source command

    hello. i am running mysql5 on mac osx 10.5. i am new to both of these. i have created a sql script file and i am trying to use it with the sql SOURCE command. when i execute the command: SOURCE mySqlScript.txt ; i get the error: Failed to open file 'mySqlScript.tx t', error: 2. i have placed this file in the /usr/local/mysql/bin directory. i have also tried adding the full path name to the script file and get the same result. where should this file be located? i would sure appreciate some help. thanks
  • iram arshad
    New Member
    • Nov 2008
    • 2

    #2
    i think the command to run afile is
    sql>@drive name:\\filename .sql
    for example:
    Sql>@c:\\ab.sql




    ITS OWN XP operating system

    Comment

    • r035198x
      MVP
      • Sep 2006
      • 13225

      #3
      Read the reference manual to find out how it is done.

      Comment

      • ted clarke
        New Member
        • Nov 2008
        • 3

        #4
        Originally posted by r035198x
        Read the reference manual to find out how it is done.

        thank you. i have read the reference manual several times. i follow the instructions exactly for using the SOURCE command. what i need to know is the location of the script file.

        Comment

        • ted clarke
          New Member
          • Nov 2008
          • 3

          #5
          still having trouble with mysql SOURCE command

          hello. i have read the sql manual and the tutorial and i believe that i am doing exactly as instructed

          i am running mysql5 on mac osx 10.5. i have created a sql script file and i am trying to use it with the sql SOURCE command.

          when i execute the command: SOURCE mySqlScript.txt ;
          i get the error: Failed to open file 'mySqlScript.tx t', error: 2.
          i have placed this file in the /usr/local/mysql/bin directory which i believe is where mysql is located.
          i have also tried adding the full path name to the script file and get the same result.

          i'm wondering:
          1) where the script file is supposed to reside
          2) does it have to be named a certain way
          3) what is error: 2?

          i would very much appreciate some help with this. thanks

          Comment

          • mwasif
            Recognized Expert Contributor
            • Jul 2006
            • 802

            #6
            Providing full path should resolve the problem. Try mysql command instead described here

            e.g.
            shell> mysql db_name < text_file

            Comment

            • tech usr

              #7
              solution to this is:

              before logging to mysql, first change directory to the path where your batch/script file is located, i.e, if your script file is hello.bat located in your desktop, then change directory to C:\Users\userna me\desktop. Then login to mysql using mysql -u username -p. now try using the source command:

              mysql> source hello.bat

              or

              you can drag drop your script file for the full path as in

              mysql> source C:\users\userna me\desktop\hell o.bat

              Very important: donot use a semicolon(;) after this command. Also, there are no quotes to be specified for the filename or path.
              Hope it works!!

              Comment

              • Judd Watts

                #8
                I had the same problem with the SOURCE command on a Perl/MySQL/Linux system. Solution: I called mysql in interactive mode using a system call from my perl script.
                NOTE that the redirection operator (<) seemed to do the job.

                ...perl code...
                system("/opt/lampp/bin/mysql --user=$usr --password=$pwd < $sql_file
                exit
                ")
                ...more perl code...

                Comment

                Working...