ryanwold.net

A civic-minded citizen seeking the singularity

Back to Entries

Copying MySQL Data and/or Databases between machines

draft
Date: 2010-09-02
Tags: commands data mysql

While I was in Washington DC, I committed to Ubuntu (10.04), switching from a Windows XP setup. I suppose it was long overdue, but being immersed in Ubuntu for 10 weeks was necessary to appreciate its open-source-yness and come to love it and its tools.

I basically had 2 1/2 months of setup effort and time invested into my laptop while on the road, but when I returned to my dual monitor setup in my home office, I had to make the switch again, from Windows XP over to Ubuntu, along with all my files, setups, projects, and data.

Early on in the transition, I needed to copy my MySQL tables between machines, which can done by exporting data to a file, copying the file to another machine, then importing it. The commands below got the job done for me. MySQL Export 1 Table - from laptop

The general syntax is:

mysqldump -u <username> -p<password> -h <host> <database name> > <filename to export to>

An example of the command is:

mysqldump -u ryan -pexamplepassword -h localhost database_name > database.sql

Because I'm storing "blob" data in my database, I also found the following command helpful. The --all-database option exports all databases, and thus does not require a to be passed. The --hex-blob option ensures the blob data will be readable for import. MySQL Export All Databases
mysqldump -u ryan -pexamplepassword -h localhost --all-databases --hex-blob > entire_database.sql

MySQL Import to a Table - to my Desktop

mysql -u <username> -p<password> -h <host> < <filename to export from>
mysql -u ryan -ppassword -h localhost < database.sql

By Ryan Wold · © 2010–2026 Ryan Wold

Licensed CC BY-NC 4.0. AI training requires a license — machine-readable terms.

Enjoyed this? — any BSV wallet, HandCash, or plain old dollars.

Leave a tip

Tips go directly to a Bitcoin SV address I control — peer to peer, no platform in between. A few thousand satoshis is a fraction of a cent; it's the gesture that counts.

From any BSV wallet

Scan the QR code with your wallet's camera, or copy the address.

177DwUfSTW8RkFBJzYYcgr1YB8ngbhTYAc

With HandCash or any paymail wallet

Paymail is an email-style address for Bitcoin wallets. Send any amount to afomi@handcash.io

First time using Bitcoin? Yours Wallet is an open-source browser extension wallet, and HandCash is an easy mobile wallet — either takes a minute to set up.

Prefer regular money? Support via OpenCollective.