## How to import database file with command prompt

Problems with the Windows version of XAMPP, questions, comments, and anything related.

### How to import database file with command prompt

Hello Friends,

In Magento E-Commerce whenever you have to import and export large sql file then apply following things:-

1>First of all open command prompt

2>Then
Example:- D:/xampp/mysql/bin/mysql.exe

3>Syntax:-

D:/xampp/mysql/bin/mysql - u root -p databasename < D:/test.sql (sql file name).

And Same thing apply when you have to use export database then apply following things:-

1> D:/xampp/mysql/bin/mysqldump -u root -p databasename > D:/text.sql(sql file name).

So, You have use when import and export sql file with command prompt this method would very much helpful to you.

Regards,
Niks
Naitik_Mistry

Posts: 2
Joined: 12. June 2013 05:47
XAMPP Version: 1.8.1
Operating System: Microsoft Windows XP

### Re: How to import database file with command prompt

Thanks for this input. I seem to have stumbled across this exact problem of needing to import a database over 2M.

Does this just overwrite an existing database, or does it append or combine anything?

In trying to do a mysqldump, I had an error indicating I had a duplicate entry for a primary key value at line 76. How do I find what line 76 the command prompt is talking about? I checked every table and there are no duplicate entries for any key value.

I once saw a line of code to take one database from one xampp install and transfer it to another in just one line of code, but I can't find it again. Do you know how to do that? This might allow synchronization between a laptop/desktop installation and a portable on a thumb drive.

Found it under:
http://dev.mysql.com/doc/refman/5.5/en/mysqldump-copying-to-other-server.html
Posted by Keith Jolley:
"""""you can also do this is one step:

local_server% mysqldump -u mysqluser --password=mysqlpasswd --databases db1 | ssh remote_server /usr/local/bin/mysql -u mysqluser -p

note that on a multi-user system you will NOT want to put in the passwords as shown because anyone on the system will be able to see them. in that case you can use the following, less convenient command. it will ask you for your password twice, once for the local server and once for the remote server:

local_server% mysqldump -u mysqluser --password=mysqlpasswd --databases db1 | ssh remote_server /usr/local/bin/mysql -u mysqluser -p"""""

Thanks again
Last edited by KeepSmiling on 04. August 2013 00:55, edited 4 times in total.
KeepSmiling

Posts: 2
Joined: 04. May 2013 05:05
XAMPP Version: Beta version
Operating System: Vista

### Re: How to import database file with command prompt

Dumping a database:
Code: Select all
mysqldump.exe --user=root --password= --max_allowed_packet=1G --host=localhost --port=3306 --default-character-set=utf8 "databasename" > "c:\path\to\dump\filename.sql"

Importing a Database
Code: Select all
mysql.exe --user=root --password= --max_allowed_packet=1G --host=localhost --port=3306 --default-character-set=utf8 "databasename" < "c:\path\to\dump\filename.sql"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
free software according to purpose of usage
XAMPP 1.8 for local development/testing only
Zend Server 6 (free) for production environments
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
It's like porn for programmers

Altrea
AF Moderator

Posts: 5309
Joined: 17. August 2009 13:05
XAMPP Version: 1.8.3-1
Operating System: W7Ux64