Languages
[Edit]
EN

MySQL - database backup using Linux Command Line

1 points
Created by:
Root-ssh
75570

In this short article we would like to show how to make MySQL database baskup using Linux Terminal (command line).

Quick solution:

mysqldump -u db_username -pdb_password -h db_hostname db_name > /path/to/backup.sql

Notes:

  • do not use space beetween┬á-p┬áand┬ápassword,
  • -h db_hostname┬áis optional (lack means┬álocalhost┬áconnection).

Practical examples

Example 1:

mysqldump -u root -pEwcrtat318jkD -h 127.0.0.1 gallery > ./2020_09_12_17_21_gallery.sql

Example 2:

/usr/bin/mysqldump -u "root" -p"SecretPa$$word" -h "127.0.0.1" "gallery" > "/path/to/backup/db/2020_09_12_17:21_gallery.sql"

Where:

  • MySQL server is installed on same machine, so we can use 127.0.0.1 host address,
  • we used┬ároot account because of allowsed┬áaccess to any database on server,
  • putting parameters to apostrophes allows us to use any characters.

See also

  1. MySQL - restore database from backup using Linux Command Line
Native Advertising
­čÜÇ
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - friendly IT community for everyone.

ÔŁĄ´ŞĆ­čĺ╗ ­čÖé

Join