Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: how do I execute .sql files?

  1. #1
    Join Date
    Jan 2007
    Location
    Davenport, Iowa
    Posts
    2,087
    Thanks
    96
    Thanked 98 Times in 96 Posts

    Default how do I execute .sql files?

    How do you run a file with an sql extension using mysqladmin? I figure this should be easy, but I am not that familiar with the mysqladmin program the one that has starfield technologies logo in the top left corner.

  2. #2
    Join Date
    Jan 2007
    Location
    Davenport, Iowa
    Posts
    2,087
    Thanks
    96
    Thanked 98 Times in 96 Posts

    Default

    meh, I got lazy and just went to the sql query section and pasted the contents of the query document into it. It works just fine that way, but I figure there is a way I could just access the file itself and execute it. It does not need to be done through mysqladmin. Any ol way will do

  3. #3
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Pipe it into mysql.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  4. #4
    Join Date
    Oct 2006
    Posts
    110
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Code:
    LOAD FROM INFILE "page.sql"
    (Please correct any mistakes)

  5. #5
    Join Date
    Oct 2006
    Posts
    110
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Words of Computer Wisdom:
    Code:
    session_start();
    /* The file will not run on its own. You must write a program to MAKE it run on its own. 
    Doing so, and making it easy for general users to do, is one of the most difficult tasks for beginning coders, 
    especially due to the fact that no one will take their ideas seriously. Also, if everyone with an idea 
    decided to make a new file extension, we'd run out of three-letter acronyms. */
    session_end();

  6. #6
    Join Date
    Jan 2007
    Location
    Davenport, Iowa
    Posts
    2,087
    Thanks
    96
    Thanked 98 Times in 96 Posts

    Default

    a little lost here. As is often the case with me this is not a very important issue, but it might be good to know for future reference. what is infile? Is there some website I could read up more on this?

    Twey, when you say pipe it into mysql it sounds like you are saying I should either enter it into the sql section of the mysqladmin page or else write a script that retrieves the data from the sql file as a variable. Am I close?

  7. #7
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    No, I meant piping it, e.g.:
    Code:
    $ (echo 'use tablename'; cat data.sql) | mysql -u username -p
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  8. #8
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    You can't execute them as far as I'm aware. They are, I believe, just text... lots of sql commands. Run them as commands in mysql. You could do it through PHP, PHPMysqlAdmin, or command line, etc.
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  9. #9
    Join Date
    Jan 2007
    Location
    Davenport, Iowa
    Posts
    2,087
    Thanks
    96
    Thanked 98 Times in 96 Posts

    Default

    This is making more sense -u and -p are the password and username. not sure about the following parts though

    Code:
    $ (echo 'use tablename'; cat data.sql) | mysql -u username -p
    It looks like it is not php, but looks close. I looked up cat on php.net and cat didn't come up.

    Gotta run to class. Catch ya in a bit.

  10. #10
    Join Date
    Jan 2007
    Location
    Davenport, Iowa
    Posts
    2,087
    Thanks
    96
    Thanked 98 Times in 96 Posts

    Default

    if it is a simple text file djr33 then that should be no problem to access and play with. I don't think I thought of that.

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
  •