CentOS MySQL Database Export and Import, centosmysql
You can use the database backup tool mysqldump to import and export mysql databases.
Mysqldump is a handy tool that comes with mysql. the/usr/local/mysql/bin (CentOS) Directory of mysql installation directory is under.
Like mysql, mysqldump is an application and cannot be executed in mysql. Remember to enter mysqldump-help to check the annual information. Mysqldump can be executed directly in any directory.
1. Export
Back up a database with mysqldump
1 |
Mysqldump-u user-p Password Database Name> (directory) Export File Name |
For example, mysqldump-uroot-p123 dbname>/root/test. SQL, press enter to complete the backup.
If you only need the table creation command, the command is as follows: shell> mysqldump-u root-p-d dbname> test. SQL
If you only need to insert the SQL command of data without the table creation command, the command is as follows: shell> mysqldump-u root-p-t dbname> test. SQL
Back up a single data table
Sometimes the database is very large, and the entire database backup is difficult to manage, so it is a separate backup.
1 |
mysqldump -uroot -p123 dbname tablename > /root/testtb.sql |
Back up multiple data tables
For example, back up the wp_posts table and wp_options table of the wordpress database to wordpress_1. SQL:
1 |
mysqldump -u root -p wordpress wp_posts wp_options > wordpress_1.sql |
Mysqldump Remote Backup
1 |
mysqldump -h ip -uroot -p123 database > c:\nowamagic.sql |
Ii. Export
mysql>source /root/test.sql
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.