Skip to content
Search

Mysqldump

lastmod 2025-05-21created 2025-05-211 edits

Dump/Load Example

Backing up a server database to an SQL file

Sample that backs up the database mydb at 192.168.0.101, port 3306, username root, password 1234, and saves it as an SQL file:

mysqldump -h 192.168.0.101 -P 3306 -u root -p1234 mydb > steel_backup.sql

Restoring to a local server from a saved SQL file

First, if the DB to restore into does not exist, create it:

mysql -h 192.168.0.101 -P 3306 -u root -p1234 -e "CREATE DATABASE IF NOT EXISTS mydb"

Then load the SQL.

mysql -h 192.168.0.101 -P 3306 -u root -p1234 mydb < steel_backup.sql

See also

author Zer0 sitemap