Mysql backup database11/20/2023 ![]() If your database is very large, you will need to compress the dump file to save the disk space. Mysqldump -user=root -password=root-password $DATABASE > "$DATABASE.sql" ĭone Backup MySQL Database with Compression You can achieve this with the following command: for DATABASE in $(mysql -user=root -password=root-password -e 'show databases' -s -skip-column-names) do It is also possible to backup all databases in your system and generates a separate dump file for each database. Mysqldump -u root –proot-password -all-databases > alldb.sql You can also backup all MySQL databases in your system using the –all-databases option.įor example, backup all databases in your system and generates a single dump file named alldb.sql, run the following command: You should see the following output: Backup All Databases Mysqldump -v -user=root -password=root-password -databases test1db test2db > testdb.sql In this case, you can perform this operation using the – -databases option.įor example, to take a backup of a database named test1db and test2db, and generates a dump file named testdb.sql, run the following command: In some cases, you may need to backup more than one database. The above command will backup the testdb database into a file called testdb_backup.sql. Mysqldump -v -u root –proot-password testdb > testdb_backup.sql ![]() Password : Specify the password of the MySQL user.ĭatabase_name : A name of the database that you want to backup.ĭump_file.sql : A name of the dump file that you want to generate.įor example, to take a backup of a single database named testdb and generates a dump file named testdb_backup.sql, run the following command: Mysqldump -v -u –p > Ī brief explanation of each parameter is shown below: You can backup a single MySQL database using the following syntax: This utility will help you to backup a local or remote MySQL database into a single file. You can backup and restore the MySQL database using the mysqldump utility.
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |