Duplicate Entire MySQL Database

后端 未结 9 1127
再見小時候
再見小時候 2020-12-04 08:04

Is it posible to duplicate an entire MySQL database on a linux server?

I know I can use export and import but the original database is >25MB so that\'s not ideal.

9条回答
  •  日久生厌
    2020-12-04 08:11

    This won't work for InnoDB. Use this workaround only if you are trying to copy MyISAM databases.

    If locking the tables during backup, and, possibly, pausing MySQL during the database import is acceptable, mysqlhotcopy may work faster.

    E.g.

    Backup:

    # mysqlhotcopy -u root -p password db_name /path/to/backup/directory
    

    Restore:

    cp /path/to/backup/directory/* /var/lib/mysql/db_name
    

    mysqlhotcopy can also transfer files over SSH (scp), and, possibly, straight into the duplicate database directory.

    E.g.

    # mysqlhotcopy -u root -p password db_name /var/lib/mysql/duplicate_db_name
    

提交回复
热议问题