SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Enthusiast PHPmySQLer's Avatar
    Join Date
    Jan 2005
    Posts
    31
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    run existing .sql script through MySQL error 1064

    I am new to MySQL, but when the book instructions are wrong it gets even more frustrating.
    I am trying to "pipe" an existing .sql script from CD through MySQL, here is the code from the book (with localhost as my host) and using dbase books:

    >mysql -h localhost -u bookorama -D books -p < bookorama.sql

    and another

    >mysql -h localhost -u bookorama -p < book_insert.sql

    i tried leaving off mysql...no help

    now I know that these both should end with ; or \g, but that's when I get the 1064 error saying to check the manual for the correct syntax. What's the fix here? Neither one of these commands work and they are both different! I've looked everywhere for help. I am assuming the scripts can be located, but I copied them to my root folder just in case.

    Here's more incorrect book instruction on how to create a table that I figured out on my own:

    CREATE TABLE tablename(columns)....no semicolon and no indication that you need identifiers for the columns. Thanx authors.

    I am using MySQL Administrator, MySQL 4.1, PHP 4.3.

    I'm making decent progress, but not having the right info is driving me nuts! I am scouring mysql.com, php.net etc when I have to, but I bought a book so I could have a comprehensive overview of what I'm doing. It doesn't seem to be helping.

    Any suggestions? Thanx in advance

  2. #2
    SitePoint Wizard guelphdad's Avatar
    Join Date
    Oct 2003
    Location
    St. Catharines, ON Canada
    Posts
    1,708
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Are you running those commands from within mysql? If so that is why you are getting the errors. If you are using Linux then use your shell to issue those commands. If you are using Windows then you want to use either the RUN or COMMAND PROMPT to run those from.

  3. #3
    SitePoint Enthusiast PHPmySQLer's Avatar
    Join Date
    Jan 2005
    Posts
    31
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I had no clue where to run those scripts from, but yes it is within mySQL. I assumed those were mySQL commands. Do I need to be at c:\mysql\bin instead of c:\mysql\bin\mysql to run the scripts from the COMMAND PROMPT? I thought I had already tried that. Can I type the command >mysql -h localhost -u bookorama -D books -p < bookorama.sql in RUN and get the same result?

  4. #4
    SitePoint Wizard guelphdad's Avatar
    Join Date
    Oct 2003
    Location
    St. Catharines, ON Canada
    Posts
    1,708
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    YOu can be wherever you want with the command prompt or using RUN. You will need to provide a full path to mysql and a full path to the .sql file.

  5. #5
    SitePoint Enthusiast PHPmySQLer's Avatar
    Join Date
    Jan 2005
    Posts
    31
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i'm not having any luck. i have a bad habit of accepting doing things the long way, so I cut and pasted the file and it works. i guess i will figure it out eventually. i've found out that i don't have PHP and Apache configured correctly so until i can make sense of the basics, all this about calling a script from within mySQL will have to wait.

    i'm off to post a thread about getting help with php.ini and httpd.conf so i can use the post method.

    thanks anyway. i won't give up too easily.

  6. #6
    SitePoint Enthusiast PHPmySQLer's Avatar
    Join Date
    Jan 2005
    Posts
    31
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I figured I should take the time to contribute what information I found that worked for my particular situation.

    Basically, I did not have book_insert.sql in the C:\mysql\bin folder, so I copied it to that location.
    From the Command prompt I typed:
    cd c:\\mysql\bin

    then

    C:\mysql\bin> mysql -u root -p < book_insert.sql

    AND IT WORKED!

    I haven't tried to re-create my mistakes, but evidently you can't run

    C:\mysql\bin\mysql> mysql -u root -p < book_insert.sql

    because that is not the root user?

    Thanks and Good Luck!

  7. #7
    SitePoint Wizard guelphdad's Avatar
    Join Date
    Oct 2003
    Location
    St. Catharines, ON Canada
    Posts
    1,708
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can run the script from anywhere. As you may have gathered because it wasn't within the directory you were running the command from you would need a full path to the directory then the file where the .sql file is located. You don't have to move the script if you do that.

  8. #8
    SitePoint Enthusiast PHPmySQLer's Avatar
    Join Date
    Jan 2005
    Posts
    31
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Really? Can you give an example of what you mean before I go copying files like a crazy man? Also I've noticed many duplicate include files in different locations, but would like to know if I need to change one thing, how can I make changes to all the files under that name?

  9. #9
    SitePoint Wizard guelphdad's Avatar
    Join Date
    Oct 2003
    Location
    St. Catharines, ON Canada
    Posts
    1,708
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    instead of running
    mysql < myfile.txt
    do
    mysql < /usr/docs/myfile/is/here/myfile.txt

    when you dump from mysql you can't name it the same it will tell you the file already exists.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •