Lost Password?


Go Back   CodeCall Programming Forum > Web Development Forum > Database & Database Programming

Database & Database Programming MySQL, Oracle, SQL, PL/SQL, ABAP, Smart Forms, and other databases and languages. A database is an organized body of related information used in many websites (including CC).

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-14-2006, 04:55 PM
Ronin Ronin is online now
Programming Professional
 
Join Date: Apr 2006
Posts: 299
Rep Power: 11
Ronin is on a distinguished road
Default Import SQL file command line

I have a SQL generated file and I would like to import it to MySQL via the command line. Can anyone post the method to do this?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 10-02-2006, 07:06 PM
mylegoh mylegoh is offline
Newbie
 
Join Date: Sep 2006
Location: London
Age: 41
Posts: 25
Rep Power: 8
mylegoh is on a distinguished road
Default

From msdos:
mysql -u username -p password < textfilewithsqlstatments.sql

From unix:
similar, but it has been a while so I cannot remember the exact syntax, it should not be too different.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 10-02-2006, 08:17 PM
Ronin Ronin is online now
Programming Professional
 
Join Date: Apr 2006
Posts: 299
Rep Power: 11
Ronin is on a distinguished road
Default

yeah, it is the same command in Linux. I forgot to post that I figured this out afterwards.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 10-09-2006, 06:44 PM
Lop's Avatar   
Lop Lop is offline
Speaks fluent binary
 
Join Date: May 2006
Posts: 1,149
Rep Power: 18
Lop will become famous soon enoughLop will become famous soon enough
Default

Except the password doesn't need to be there. Just:

mysql -u username -p < textfile.sql
__________________
Lop
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 01-07-2008, 12:08 PM
Atmaweapon Atmaweapon is offline
Newbie
 
Join Date: Jan 2008
Posts: 1
Rep Power: 0
Atmaweapon is on a distinguished road
Default

i had to include the database name:
mysql -u <username> -p <database> <textfile.sql>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #6 (permalink)  
Old 01-23-2008, 12:19 PM
zerostar's Avatar   
zerostar zerostar is offline
Newbie
 
Join Date: Jan 2008
Posts: 12
Rep Power: 0
zerostar is on a distinguished road
Default

heya

I am copying a .sql db form a production server to a dev server. Do I have to place the .sql file in a certain directory to do the import from the cmd line? I can't seem to be able to complete the import.

I'm running the latest revision of wampserver.

thanks!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 01-23-2008, 12:25 PM
Jordan's Avatar   
Jordan Jordan is offline
Administrator
 
Join Date: Nov 2005
Location: Hendersonville, NC
Posts: 9,224
Last Blog:
Ext JS or Ext GWT
Rep Power: 20
Jordan is just really niceJordan is just really niceJordan is just really niceJordan is just really nice
Send a message via ICQ to Jordan Send a message via AIM to Jordan Send a message via MSN to Jordan
Default

If you execute it as:

mysql -u <username> -p <database> textfile.sql

Then the file needs to be in the same directory you are currently in. If you know where the file is you can do:

mysql -u <username> -p <database> /path/to/file/textfile.sql
__________________
CodeCall Blog | CodeCall Wiki | Shareware Site | Linux Forum | Write a Blog
The CodeCall Wiki is now fully integrated with vBulletin users! Check it out and add some new pages!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 01-23-2008, 12:46 PM
zerostar's Avatar   
zerostar zerostar is offline
Newbie
 
Join Date: Jan 2008
Posts: 12
Rep Power: 0
zerostar is on a distinguished road
Default

Thanks for the reply

I'm still getting an ERROR 1604 (syntax). Here is what I'm entering at the mysql> prompt:

Code:
mysql -u username -p databasename < dbtoimport.sql;
is this correct?

btw - this is from a sqldump from the Prod server.

Last edited by zerostar; 01-23-2008 at 12:48 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 01-23-2008, 12:48 PM
Jordan's Avatar   
Jordan Jordan is offline
Administrator
 
Join Date: Nov 2005
Location: Hendersonville, NC
Posts: 9,224
Last Blog:
Ext JS or Ext GWT
Rep Power: 20
Jordan is just really niceJordan is just really niceJordan is just really niceJordan is just really nice
Send a message via ICQ to Jordan Send a message via AIM to Jordan Send a message via MSN to Jordan
Default

No, remove the ;
__________________
CodeCall Blog | CodeCall Wiki | Shareware Site | Linux Forum | Write a Blog
The CodeCall Wiki is now fully integrated with vBulletin users! Check it out and add some new pages!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 01-23-2008, 12:51 PM
zerostar's Avatar   
zerostar zerostar is offline
Newbie
 
Join Date: Jan 2008
Posts: 12
Rep Power: 0
zerostar is on a distinguished road
Default

hmm...tried that but it just goes to the next line. sorry 'bout the n00bness

I already created the DB and I'm just trying to import the structure and data from the dump file - is this procedure correct? They are named the same - would that present this problem?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Project: ionFiles - Joomla Simple File Download Jordan Community Projects 324 11-10-2008 08:34 PM
Project: ionFiles - Joomla Simple File Download - Mirror 2 Jordan ionFiles 6 11-06-2008 01:24 PM
Windows XP Tricks & Tips!!!!..new ones. pranky Tutorials 9 08-23-2008 04:22 PM
Best program for SQL database manipulation Rhadamanthys Database & Database Programming 3 07-02-2007 03:32 PM
text file manipulations in vb6.0 Ronin_paes Visual Basic Programming 3 06-11-2007 05:54 AM


All times are GMT -5. The time now is 12:27 PM.

Contest Stats

WingedPanther ........ 2753.6
Xav ........ 2704
Brandon W ........ 1702.32
John ........ 1207.73
marwex89 ........ 1175.24
morefood2001 ........ 966.05
dcs ........ 655.75
Steve.L ........ 475.59
orjan ........ 418.58
Aereshaa ........ 383.54

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 98%

Ads