Results 1 to 6 of 6
  1. #1
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    161

    Unanswered: SQL file containing INSERT - need to add USE database

    Hi

    I created a .sql file that has many INSERT statements - which resulted in a 220MB file - after zipping its 80MB - I uploaded the file to the server which took some hrs as net speed is low here.

    Now I realized that I should have added USE database_name in the first line and then execute in command line using mysql < hugefile.sql
    But now that USE database_name isnt there, how can I get the command line tool to execute the sql file for a particular database_name ?

    Thanks

  2. #2
    Join Date
    Apr 2005
    Location
    Baltimore, MD
    Posts
    297
    You can read the dump file back into the server like this:
    Code:
    shell> mysql db_name < backup-file.sql
    Or like this:
    Code:
    shell> mysql -e "source /path-to-backup/backup-file.sql" db_name

  3. #3
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    161
    But how do I get a sql file to be executed when password is involved ?
    Code:
    -bash-2.05b$ mysql -u username database_name -p < insert_statements.sql
    Will this work ?

  4. #4
    Join Date
    Apr 2005
    Location
    Baltimore, MD
    Posts
    297
    Code:
    --user=u --password=p

  5. #5
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    161
    Ah...I see - thought -u and -p were the only ways possible !
    Anyway, it worked even with
    Code:
    -bash-2.05b$ mysql database_name < insert_statements.sql -u username -p

  6. #6
    Join Date
    Apr 2004
    Location
    Europe->Sweden->Stockholm
    Posts
    71
    (Deleted – the solution is already presented )

    Weird indeed. Saw no other posts – getting old?

Posting Permissions

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