Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 11
  1. #1
    Member
    Join Date
    Jan 2004
    Posts
    68
    Member #
    4547
    I'm learning MySQL, using the book in the title of this thread and my question is when running an sql file to create tables, and fill in those tables I'm given a line like the following:

    mysql -h host -u username -D dbname -p < sqlfile.sql

    What does the "<" mean? Whenever I do that MySQL returns cannot find specified file.

    In the book it mentions "Using file redirectioin is handy...because it means you can edit your SQL in a text-editor of your choice before executing it." That does sound very handy, but how do I get it to work the way it says in that quote?

    Thanks for your help.

    Jake

  2.  

  3. #2
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,715
    Member #
    5580
    Liked
    717 times
    If you view the CD they supply, they have .sql examples for various
    chapters. In my book, you're referring to Chapter 8 (page 195).

    The book shows:

    > mysql -h host -u bookorama books -p < bookorama.sql

    (it assumes you enter in the correct host, user, password).

    Executing that line command will load a table with the contents of
    what's in "bookorama.sql"

    If you go onto the CD and find it, and click on it ... it's actually just
    a text file. You can create text files, give them the extension of .sql
    and use them to create your tables.

    That's why it's so handy ... you do it all using Notepad and run the whole
    works in one step.

    < = goes from a file into mysql ... it's like the direction that the data is going.


  4. #3
    Member
    Join Date
    Jan 2004
    Posts
    68
    Member #
    4547
    Whenever I do that MySQL returns cannot find specified file. So does the "<" just mean input the whole file location (e.g. c:\my docs\ etc.)?

  5. #4
    Senior Member filburt1's Avatar
    Join Date
    Jul 2002
    Location
    Maryland, US
    Posts
    11,774
    Member #
    3
    Liked
    21 times
    < sends the contents of the file to the right of the < to what's left of the <.

    Example:
    Code:
    mysql some text here
    is essentially the same as:
    Code:
    mysql < foo.txt
    ...where foo.txt contains "some text here."

    All the command in your first post does is execute the contents of sqlfile.sql on the specified host with the specified username and password. -h isn't really necessary most of the time given MySQL usually runs on the same server as the web server.
    filburt1, Web Design Forums.net founder
    Site of the Month contest: submit your site or vote for the winner!

  6. #5
    Member
    Join Date
    Jan 2004
    Posts
    68
    Member #
    4547
    Right, I understand that. So I need a specific file location then?

  7. #6
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,715
    Member #
    5580
    Liked
    717 times
    Dr. Jake....

    Are you running your MySQL on your own PC/Server?

    If you're using a remote server (a webhost with MySQL), that would
    be a problem, since it's looking for a file in the same directory.
    It's assuming you're using your own stand-alone PC.

    Or, tell it where to look ...

    mysql -h host -u username -D dbname -p < ..\files\sqlfile.sql

    However the path works on a PC/Server.


  8. #7
    Member
    Join Date
    Jan 2004
    Posts
    68
    Member #
    4547
    I set up a server on my computer. What directory does the file have to be in so that I can just put the filename in and it works without the long path?

  9. #8
    Member
    Join Date
    Jan 2004
    Posts
    68
    Member #
    4547
    I got another question with regard to this book's tutorials. One of the instructions is to insert someone manually and only insert data for two of the colums. When I attempt this I get an error (Error 1364: No defualt type). However I had mysql describe the table and the default value for all the columns is NULL, what is the cause of this error?

  10. #9
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,715
    Member #
    5580
    Liked
    717 times
    DrJake,

    Now your getting into an area where I'm no expert. (sorry).

    I used the book to learn PHP/MySQL for a remote webhost server.
    I've never installed anything on my own PC.

    Perhaps there's a MySQL expert here that will see this thread.


  11. #10
    Member
    Join Date
    Jan 2004
    Posts
    68
    Member #
    4547
    What about my second question. Since you've gone through the same book did you run into this problem?


Page 1 of 2 1 2 LastLast

Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 03:57 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com