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?
17 replies to this topic
#1
Posted 14 September 2006 - 12:55 PM
|
|
|
#2
Posted 02 October 2006 - 03:06 PM
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.
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.
Edited by John, 15 July 2009 - 05:56 AM.
#3
Posted 02 October 2006 - 04:17 PM
yeah, it is the same command in Linux. I forgot to post that I figured this out afterwards.
#4
Posted 09 October 2006 - 02:44 PM
Except the password doesn't need to be there. Just:
mysql -u username -p < textfile.sql
mysql -u username -p < textfile.sql
#5
Posted 07 January 2008 - 09:08 AM
i had to include the database name:
mysql -u <username> -p <database> <textfile.sql>
mysql -u <username> -p <database> <textfile.sql>
#6
Posted 23 January 2008 - 09:19 AM
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!
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!
#7
Guest_Jordan_*
Posted 23 January 2008 - 09:25 AM
Guest_Jordan_*
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
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
#8
Posted 23 January 2008 - 09:46 AM
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?
btw - this is from a sqldump from the Prod server.
I'm still getting an ERROR 1604 (syntax). Here is what I'm entering at the mysql> prompt:
mysql -u username -p databasename < dbtoimport.sql;
is this correct?
btw - this is from a sqldump from the Prod server.
#9
Guest_Jordan_*
Posted 23 January 2008 - 09:48 AM
Guest_Jordan_*
No, remove the ;
#10
Posted 23 January 2008 - 09:51 AM
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?
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?
#11
Posted 23 January 2008 - 10:55 AM
ok figured out what my issue was :o and yes - n00bness at work...
I had already logged into mysql.exe when I was trying to execute the command. I had to back out to the bin directory and then run the command.
up and running (*yay!*)
I had already logged into mysql.exe when I was trying to execute the command. I had to back out to the bin directory and then run the command.
up and running (*yay!*)
::
[ z ]
[ z ]
#12
Posted 25 January 2008 - 07:36 AM
From inside mysql you can paste the entire contents of the SQL dump. that will also work although I've not tested it.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account


Back to top









