Skip to content
BackupScope

WordPress Database Backups Without mysqldump: How It Works

Many hosts block mysqldump. Here is how a WordPress database can be exported safely through PHP, including large tables, big rows and binary data.

By the BackupScope team2 min read

mysqldump is the classic way to export a MySQL database. On a lot of WordPress hosting it is simply not available: PHP is not allowed to run command-line programs. A backup that depends on it either fails or quietly leaves the database out.

Exporting through PHP

WordPress already has a database connection. A backup can use it to read each table and write a standard SQL file: CREATE TABLE statements followed by INSERTs. The result imports anywhere a normal dump would.

The hard part is doing that safely on real sites.

Page through tables

Selecting a whole table at once loads it into memory. On a table with millions of rows, that fails. Instead:

  • read rows in pages ordered by the primary key ("keyset pagination"),
  • remember the last key, and continue from there in the next request.

Memory stays flat no matter how large the table is, and the export can stop and resume between requests.

Keep statements under max_allowed_packet

MySQL rejects any single statement larger than max_allowed_packet (often a few megabytes by default). If an export writes one INSERT for a row holding a 20 MB serialized value, the backup looks fine but the import fails.

The fix is to write very large values in chunks: insert the row with the start of the value, then append the rest with UPDATE … SET col = CONCAT(col, …) statements. Every statement stays small, and the restored value is identical.

Binary and BIT columns

Some columns cannot be written as plain text:

  • BLOB / BINARY data must be written as hexadecimal literals.
  • BIT columns must be written as numbers, or they come back wrong.
  • Geometry columns are binary too.

Getting these wrong produces a backup that imports without errors and still corrupts data.

How BackupScope does it

BackupScope's exporter works through WordPress's own connection, pages through tables by key, writes large values in chunks so imports work with a default max_allowed_packet, and handles binary and BIT columns explicitly. The export runs in resumable steps, like the rest of the backup, and ends with a footer so a truncated file is detected. Read more in the Large Site Guide.

Restoring the export

The file is plain SQL. Import it with phpMyAdmin, Adminer, or for large files the command line:

mysql -u USER -p DATABASE_NAME < database.sql

The Restore Guide covers the full process, including what to change if the domain moved.

Frequently asked questions

Can I back up a WordPress database without phpMyAdmin or mysqldump?

Yes. A backup plugin can export every table through PHP using WordPress's database connection. The result is a normal .sql file you can import with phpMyAdmin, Adminer or the mysql command.

What is max_allowed_packet and why does it matter for backups?

It is the largest single statement MySQL accepts. If a backup writes one huge INSERT for a big row, importing it fails. Writing large values in chunks keeps every statement under the limit.

Is a PHP database export slower than mysqldump?

It can be, but done in pages it is predictable and works on hosts where mysqldump is not available at all, which matters more than raw speed.

Backup your site. Understand your storage. Clean it safely.

BackupScope makes full, verified backups of your files and database, built for large sites. Pro adds schedules, off-site copies, restore, storage analytics and safe cleanup.

Get BackupScope FreeSee Pro