Backing up and Restoring MySQL with mysqldump
I backup and restore databases across servers every few months, but each time I have to resort to reading this very verbose documentation. The steps below are a no fuss way to do this each time.
Backup Server
SSH into the server with the database that you wish to backup run the following command.mysqldump -u root -p $DB_NAME > $DB_NAME.sql
Copy the File to Destination Server
Using scp, we can securely transfer the backupscp $DB_NAME.sql $USER@$SERVER:
Restore on Destination Server
SSH into the server with the database that you wish to restore. From the the previous step the backup file should now be located in the root directory.- Create new database
mysql -u root -p -e 'CREATE DATABASE $DB_NAME'
- Restore your backup
mysql -u root -p $DB_NAME < $DB_NAME.sql
Thank you for reading! Share your thoughts with me on bluesky, mastodon, or via email.
Check out some more stuff to read down below.
Most popular posts this month
- SQLite DB Migrations with PRAGMA user_version
- Edge Detection with Inkscape
- Using cgit
- Making cgit Pretty
- Lev Lazinskiy
Recent Favorite Blog Posts
This is a collection of the last 8 posts that I bookmarked.
- Pluralistic: Enshittification and Reverse Centaurs go global (29 Jul 2026) from Pluralistic: Daily links from Cory Doctorow
- AI Mania Is Eviscerating Global Decision-Making from Ludicity
- No-One Escapes the Permanent Underclass from Fernando Borretti
- Is it ethical to use AI? from charity.wtf
- The logical destination of LLMs from Andy Bell
- Revised rules of engineering leadership. from Irrational Exuberance
- The circus freaks of open source from Drew DeVault's blog
- Clanker: A Word For The Machine from Armin Ronacher's Thoughts and Writings
Articles from blogs I follow around the net
Now we have a timeline of the OpenAI accidental attack against Hugging Face
OpenAI gave a last-minute presentation at the Black Hat security on Wednesday about "the Hugging Face Incident" (previously on this blog). The video was published yesterday. It's short and information dense and well worth watching, in particular because it...
via Simon Willison's Weblog: Entries August 7, 2026Spoiler: Wil Wheaton is a Wizard
I am holding pink pages in my hand, reviewing them before I collate them into my script. A magic battle ensues between Wil and Bert (fireballs, energy bolts, conjured beasts, etc.) I look at the script again, to make sure I haven’t misread it. Yeah, it rea...
via WIL WHEATON dot NET August 7, 2026Seeing like a state
The post about the dark mode toggle reminded me of two similar things rattling in my brain. On the positive side, here’s a delightful interaction from macOS. I can easily maximize the window to take up half the screen, but the moment I start dragging it, i...
via Unsung August 7, 2026Generated by openring