SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Zealot
    Join Date
    Dec 2000
    Location
    Norcross, GA
    Posts
    136
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Inserting/outputting files with MySQL from the command prompt

    Can a file be inserted to a mysql table from a unix(linux) command prompt?

    Also, can I query the same table and output the data to a filename.ext in a specified directory?
    - Mike
    http://www.georgiaoffroad.com

  2. #2
    SitePoint Member
    Join Date
    Apr 2002
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I export data in mysql Win32 environment using the mysqldump binary file, which I believe would be the same in Unix, see the manual at http://www.mysql.com/doc/m/y/mysqldump.html

    For importing, yes it can, and I do this aswell. In this case I have a .sql file that uses the SQL command:

    Code:
    LOAD DATA INFILE '(path to file here)'
    The file it reads in is delimited, and there is a load of syntax for defining this. For more, check out the manual here:
    http://www.mysql.com/doc/L/O/LOAD_DATA.html

    The SQL file is then run by 'piping' it to the mysql executable:
    Code:
    mysql [database name] < file.sql
    HTH
    ><


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
  •