Results 1 to 2 of 2

Thread: batch files

  1. #1
    Join Date
    Apr 2003
    Posts
    4

    batch files

    Call me thick but i'm just doing an assignment for college (so yes i've been taught absolutley nothing about using mysql. I have created a .dat file and placed it in c:\mysql\bin
    How can I get mysql to run this file to populate a database with the tables/info/constraints that this file contains? I have tried following the manual but the:
    shell> mysql -h host -u user -p < batch-file
    Enter password: ********
    clearly isn't working for me.
    If my directory for mysql is c:\mysql\bin, host is 'alans', user is alan, my database is 'test1' and my batch file is 'dbsetup.dat'then what do I LITERALY type at the dos prompt?(forget any confusing and meaningless syntax example like the example above)
    Can you (preferably) run this file while mysql is running?
    Cheers - FAlCLITERALY

  2. #2
    Join Date
    Feb 2003
    Location
    Johannesburg, South Africa
    Posts
    145
    First of all, I don't know how your data file looks like, so I will give solutions for two scenarios:

    Scenario 1 :
    You have DATA in a text file, similar to CSV.

    Example: The Unix passwd file

    Solution: Use the mysqlimport utility.

    Documentation: http://www.mysql.com/doc/en/mysqlimport.html AND http://www.mysql.com/doc/en/LOAD_DATA.html

    Scenario 2 :
    You have SQL Statements in a data file.

    Example: A data file created by mysqldump

    Solution: Log on to MySQL and use:
    Code:
    mysql> \. /path/to/sqldatafile/filename.sql
    Other References
    MySQL Command Line Options

    As this is another of them home work scenario's, I belief the aim of the exercise was to teach you something, and the only way you will learn is to study the documentation. Use the references here as a starting point, and then ask specifics.

    Cheers & Have Fun...

Posting Permissions

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