import/export mysql database via command line

Pranaam to all bhai ji _/\_
In this tutorial we will learn how to import/export SQL database to MYSQL server using commandline

Importing Database
so first of all we will go for importing database to MYSQL server
lets suppose we have a database having name 'indishell' in sql server and we want to upload our dumped database(a file which contains schema and data entry for database tables/columns) to this database
dump database file name is dump.sql and we want to upload it to database 'indishell'
so  command will be

mysql  -u user_name -p  database_name <  dump_file_name

 -u field is for username like i want to use user 'root'
-p stands for password of the sql server user (in my case , my sql user is root and its password is indishell)
datbase_name is the name of the database to which we want to upload our dumped database (this is indishell in my case)
dump_file_name  is the name of the database dump file (in my case it is dump.sql)

so command will be like this
mysql  -u root  -p  indishell  < dump.sql

as you will press enter after this command , mysql server will ask for password of the user using which you are entering to sql server (mine one is root and its password is indishell) .
type password and press enter .
thats it ;)

Exporting Database
in exporting, we dump database in a file from database
means , we have a database having name indishell and want to dump it in a file .this is done for generating a copy of database for backup purpose or using same database for other application
so lets start :)
again , i have user having name 'root' and its password is 'indishell' , database name is 'indishell' and want to dump database to a file having name in.sql
command will be
mysqldump  -u root -p  indishell > in.sql

after execution of this command , tpe password for sql user and you will get a file having name in.sql in your current directory .
you can do this in windows OS too , you just need to find out mysql binary (for wamp server it is in C:\wamp\bin\mysql\mysql5.5.8\bin)
for importing database use mysql.exe
for exporting database use mysqldump.exe

this is how to import database in wamp via command line

for dumping database you need to you mysqldump.exe binary in C:\wamp\bin\mysql\mysql5.5.8\bin

this command will dump database 'indishell' in directory C:\wamp\www\vulnerable\db with filename in.sql
 in xampp server, you need to open xampp panel and click on "shell" button and run same command as we are using in linux :)
Enjoy ;)

Thank you :)

Greetz to :- Guru ji Zero , code breaker ica, Aasim shaikh,Reborn, Raman kumar rana,INX_r0ot,Darkwolf indishell, Chinmay Pandya,L0rd Crus4d3r,Hackuin ,Silent poison India,Magnum sniper,Atul Dwivedi,ethicalnoob Indishell,Local root indishell,Irfninja indishell Hardeep bhai,Mannu,Viki and AR AR bhai ji <3

Share this post


:) :-) :)) =)) :( :-( :(( :d :-d @-) :p :o :>) (o) [-( :-? (p) :-s (m) 8-) :-t :-b b-( :-# =p~ :-$ (b) (f) x-) (k) (h) (c) cheer

© 2009 Start With Linux | Mannu Linux
Designed by cyb3r.gladiat0r
Posts RSSComments RSS
Back to top