What are the common commands for mysqldump in MySQL?
MySQL's mysqldump Concise Common Command Guide
Export data
1. Back up the data and table structure of all databases
Mysqldump-uroot-ppassword-A > all.sql
2. Only backup table structure, do not back up data
Mysqldump-uroot-ppassword-A-d > database.sql
3. Only back up the database, not the table structure
Mysqldump-uroot-ppassword-A-t > data.sql
4. Back up the data and table structure of a single database (only backup data or table structure can be-t or-d)
Mysqldump-uroot-password dbname > dbname.sql
5. Back up the data and table structure of multiple databases at once (only backup data or table structure can be-t or-d)
Mysqldump-uroot-ppassword db1 db2 > db2.sql
Import data
1. Import data directly through command redirection
Mysql-uroot-ppassword
< all.sql 2、在mysql终端source文件 mysql -uroot -ppassword mysql>Source all.sql
3. Restore a single database (you can also source through the mysql terminal)
Mysql-uroot-ppassword db1
< db.sql 注意:郑州较好的妇科医院 http://www.kd0371.com/ 导入数据的时候,要先确认一下sql文件是否包含建表建库语句,不然会导致导入失败。 压缩ibdata1空间的方法: 对一些没用的表进行清空: truncate table xxx; 然后optimize table xxx; 对压缩ibdata1空间没有效果,因为对共享表空间不起作用。mysql ibdata1存放数据,索引等,是MYSQL的最主要的数据。 简明压缩ibdata1的方法是采用mysqldump备份所有数据库后重建所有数据库,步骤如下: mysqldump -uroot -ppassword --all-databases >Backup.sql exports the data and table structure of all databases
Stop the MySQL service service.
Delete ibdata1, ib_logfile0 and ib_logfile1 files.
Restart the MySQL service service.
Import all backup data and table structure mysql-uroot-ppassword < backup.sql.
In this way, the three files of ibdata1, ib_logfile0 and ib_logfile1 will be re-established, and the storage space will be greatly reduced.