If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > SQL file containing INSERT - need to add USE database

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-31-06, 07:15
anjanesh anjanesh is offline
Registered User
 
Join Date: Feb 2005
Location: Mumbai, India
Posts: 161
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
Reply With Quote
  #2 (permalink)  
Old 01-31-06, 08:50
jfulton jfulton is offline
Registered User
 
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
Reply With Quote
  #3 (permalink)  
Old 01-31-06, 11:56
anjanesh anjanesh is offline
Registered User
 
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 ?
Reply With Quote
  #4 (permalink)  
Old 01-31-06, 12:42
jfulton jfulton is offline
Registered User
 
Join Date: Apr 2005
Location: Baltimore, MD
Posts: 297
Code:
--user=u --password=p
Reply With Quote
  #5 (permalink)  
Old 01-31-06, 22:43
anjanesh anjanesh is offline
Registered User
 
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
Reply With Quote
  #6 (permalink)  
Old 02-04-06, 05:34
snorp snorp is offline
Registered User
 
Join Date: Apr 2004
Location: Europe->Sweden->Stockholm
Posts: 71
(Deleted – the solution is already presented )

Weird indeed. Saw no other posts – getting old?
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On