The MySQL database import and export can be mysqldump with the database backup tool
The Mysqldump tool is a very handy gadget for MySQL, with the MySQL installation directory/usr/local/mysql/bin (CentOS) being under.
Like MySQL, Mysqldump is an application that you can't perform under MySQL. Remember, enter MYSQLDUMP–HELP to see relevant information. Mysqldump can be executed directly under any directory.
First, export
Backing up the database with mysqldump
1
|
mysqldump -u用户 -p密码 数据库名 > (目录)导出文件名
|
such as: mysqldump-uroot-p123 dbname >/root/test.sql Enter to complete the backup directly.
If you only need to build a table directive, the command is as follows: Shell> mysqldump-u root-p-D dbname > Test.sql
If you only need SQL commands to insert data and do not need to create a table command, the command is as follows: shell> mysqldump-u root-p-T dbname > Test.sql
Backing up a single data table
Sometimes the database is very large, the whole library backup is not good management, then separate backup.
1
|
mysqldump -uroot -p123 dbname tablename > /root/testtb.sql
|
Backing 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
|
Second, import
Mysql>source/root/test.sql
How to export a database in the CentOS environment