bhylu.com

Advertisements

SQL Backup DB

A backup is useful only if you can restore the right data within the time your application can tolerate. Copying a few query results is not the same as backing up a database's structure, data, and required operational state.

Understand the idea

For a local MySQL or MariaDB lab, a logical dump is a practical starting point. Run the shown command in a terminal, not in the SQL editor. The password prompt avoids putting a password directly in the command text. Consistency options depend on table engines and concurrent schema changes; coordinate real production backups with the server's documented procedure.

Where to try it

Use Terminal: MySQL / MariaDB for this example. It is shown for reading and local practice; the SQLite browser editor does not run this dialect or supply application-driver parameters. Follow the setup and explanation below in a disposable local environment.

SQLite sample data · MySQL / MariaDB sample data · See the sample tables

A worked example

Terminal: MySQL / MariaDB

mysqldump -u root -p --single-transaction bhylu_sql_lab > bhylu_sql_lab.sql

Read the result

The terminal writes a SQL dump file if the tool, account, and database are available. Restore into a separate lab database and compare table counts before considering the backup tested. MariaDB installations may provide mariadb-dump instead.

Try one change

Restore the lab dump under a different database name. Check row counts and one joined report without overwriting the original database.