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?
From msdos:
mysql -u username -p database_name < textfilewithsqlstatments.sql
From unix:
similar, but it has been a while so I cannot remember the exact syntax, it should not be too different.
Last edited by John; 07-15-2009 at 06:56 AM.
yeah, it is the same command in Linux. I forgot to post that I figured this out afterwards.
Except the password doesn't need to be there. Just:
mysql -u username -p < textfile.sql
i had to include the database name:
mysql -u <username> -p <database> <textfile.sql>
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!
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
Thanks for the reply
I'm still getting an ERROR 1604 (syntax). Here is what I'm entering at the mysql> prompt:
is this correct?Code:mysql -u username -p databasename < dbtoimport.sql;
btw - this is from a sqldump from the Prod server.
Last edited by zerostar; 01-23-2008 at 09:48 AM.
No, remove the ;
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?
There are currently 6 users browsing this thread. (0 members and 6 guests)
Bookmarks