Scenario:
You are working as MySQL or MariaDB Admin and you have taken the full backup of a database by using mysqldump utility, Now you need to restore that backup to database, how would you do that?
Solution:
To take full backup of a database in MySQL or MairaDB , below mysqldump command can be used.
shell > mysqldump --user=YourUserName --password=PasswordfortheUser DatabaseName >/DestinationDirectory/BackupFileName.sql
shell > mysqldump --user=root --password=DBA123 testdb >/mysqlbackup/testdb.sql
To Restore, you will be using below command. Make sure you have created empty database first , otherwise you will get an error.
shell > mysql --user=UserName --password=PasswordforUser DatabaseName < /SourceDirectoryforBackup/BackupFile.sql
Let's say if we would like to restore testdb, I can use below statement.shell > mysql --user=root --password=DBA123 testdb < /mysqlbackup/testdb.sql