How to export MySQL database via command line in Linux

The mysqldump command is used to create textfile “dumps” of databases managed by MySQL.
These dumps are just files with all the SQL commands needed to recreate the database from scratch. The process is quick and easy.

wexx0# mysqldump -u c1xx_cxxtao -p cxxp_cxxtao > /tmp/mysqlnewdump.sql
Enter password:

wxx10# pwd

wxx10# ls
config.php dcaconfig.php fancyUpload.php langconfig.php localconfig.php timezones.php tinyMCE.php
countries.php editArea.php initconfig.php languages.php tcpdf.php tinyFlash.php tinyNews.php
wxx10# scp /tmp/mysqlnewdump.sql's password:

mysqlnewdump.sql 100% 2903KB 2.8MB/s 00:00

Note: FYI
Sometimes you may need to import and export your MySQL databse from command line. Then this maybe could help you out.

#mysqldump -u database_user_name -p database-name > dbname.sql
Behind -u you should put your database user name
-p this is for the database password option
When you have done this command it will ask for the database password,
so you put the password in and press enter.


#mysqldump -u root -p my_db > /home/kudda/my_db_backup.sql
The example above will dump my_db into /home/kudda
and it will land under the name of my_db_backup.sql. Also i am using mysql root to easily dump database,
so when i written -u after that you shall write root.

Note: On the other node “alxxxa” to access the path where the mysqldump file is copied into

root@alxxxa:~# pct enter 103
root@Pxxxxo:~# /var/www/pplxxx.ixxx/
 bash: /var/www/ppplxxx.ixxx/: No such file or directory

 root@Plxxxro:~# ls
 root@Plxxxro:~# /var/www/pplxxx.ixxx/
 bash: /var/www/pplxxx.ixxx/: No such file or directory

 root@Plxxxro:~# cd /var

 root@Plxxxro:/var# ls
 backups cache lib local lock log mail opt run spool tmp www

 root@Plxxxro:/var# cd www

 root@Plxxxro:/var/www# ls
 pplxxx.ixxx html

 root@Plxxxxro:/var/www# mv pplxxx.ixxx/ pplxxx.ixxx/

 root@Plxxxro:/var/www# ls
 html pplxxx.ixxx

 root@Plxxxro:/var/www# ls
 html pplxxx.ixxx

 root@Plxxxro:/var/www# cd pplxxx.ixxx/

 root@Plxxxro:/var/www/pplxxx.ixxx# ls
 CHANGELOG.txt contao css_saas.css index.php navi_brands_bak.css navi_trading_bak.css sitemap.xml tl_files
 GPL.txt cron.php css_start.css lang.css navi_grey.css plugins sitemap_en.xml typolight
 INSTALL.txt css.css css_trading.css mysqlnewdump.sql navi_saas.bak.css print.css stats
 LGPL.txt css_brands.css error navi.css navi_saas.css robots.txt system
 basic.css css_grey.css ie6.css navi_brands.css navi_trading.css share.php templates

Notify of
Inline Feedbacks
View all comments
Would love your thoughts, please comment.x