The database is the backbone to all WordPress websites, which is why knowing how to back up and restore MySQL database is a crucial step to getting prepared when needed.
Here is how you can do it and do it all from the shell command line without the popular phpMyAdmin.
mysqldump is the command line we will be using to backup MySQL database data. Basically, it reads the data from the database and writes them to a dump file with all the SQL commands needed to re-create the database from scratch.
To backup a single database, use
$> mysqldump -u root -p db-name > db-backup.sql Enter password:
Type in MySQL’s root password and it’s done.
You can also backup multiple databases by use the –databases switch.
$> mysqldump -u root -p --databases db1,db2,db3 > db-backups.sql
Or, simply use the –all-databases to backup all databases you have loaded in your MySQL.
$> mysqldump -u root -p --all-databases > db-all-backup.sql
If your database is very big, it’s a good idea backing up the database with compression. Just pipe the output to the gzip command line and you will get the compressed backup copy in gzip format.
$> mysqldump -u root -p db-name | gzip -9 db-backup.sql.gz
Since the backup file is full of SQL commands, we can restore databases by simply telling mysql command to run the commands in the backup file and put the data into the proper database.
If the backup file is only for a single database, use
$> mysql -u root -p db-name < db-backup.sql
If the backup file contains multiple databases, here is how to use it to restore to a specific database.
$> mysql -u root - p --one-database db-name < db-all-backup.sql
If using Copilot right from the Taskbar isn't your thing, you should disable it. Even…
In an environment where standardizing things does matter, setting default fonts in Microsoft Office apps…
Wake-On-LAN is a networking standard that lets you wake up a computer from either a…
First of all, this is not to bypass a PDF file that requires a password…
Microsoft has been lurking about the idea of placing the Outlook navigation bar to the…
One colleague came up to me the other day asking me to take look at…