MySQL 8.0 : Backup with mysqldump
For Backup and Restore MySQL Data, it's possible to run with [mysqldump].
[1]. Run [mysqldump] to take dump data of MySQL.
# lock all tables and dump all data in MySQL
# during dumping data, reading is also locked, so acutually impossible to use Databases
[root@www ~]# mysqldump -u root -p --lock-all-tables --all-databases --events > mysql_dump.sql
Enter password:
# dump all data without locking but with transaction
# ensured data integrity by [--single-transaction] option
[root@www ~]# mysqldump -u root -p --single-transaction --all-databases --events > mysql_dump.sql
Enter password:
# dump specific database
[root@www ~]# mysqldump -u root -p test_database --single-transaction --events > mysql_dump.sql
Enter password:
[2]. For restoring data from backup on another host, run like follows.
Before restoring, transfer dump data to the target host with [rsync] or [scp] and so on.
# for all dumped data, simply import a file
[root@node01 ~]# mysql -u root -p < mysql_dump.sql
Enter password:
# for dumped data with specific database,
# create a empty database first with the same DB name and next, import a file
[root@localhost ~]# mysql -u root -p test_database < mysql_dump.sql
Enter password:
Comments
Post a Comment