habibzain Just husband, father and enthusiastic men about System Administration. Love to write short article about it. Perhaps can help and be useful for others.

Mysql Backup and Restore from CLI

1 min read

Hi Dude, this article is simple method how to backup and restore database mysql from command line cli. To backup and restore a MySQL database from the command line, we can use native command sql mysqldump and mysql commands, respectively. Lets do it.

Backup Mysql One Database from cli

Backup One Database

  1. Open a terminal and navigate to the directory where you want to save the backup file.
  2. Run the following command to create a backup of the database:
mysqldump -u username -p database_name > backup_file.sql
  1. Replace username with the username you use to connect to the MySQL server and database_name with the name of the database you want to back up. The > operator redirects the output of the mysqldump command to a file named backup_file.sql.
  2. Enter the password for the MySQL user when prompted.
  3. The backup file will be created in the current directory.

Restore One Database

Run the following command to restore the database.

mysql -u username -p database_name < backup_file.sql

Backup All Database

Execute this command create a backup of all databases:

mysqldump -u username -p --all-databases > backup_file.sql

Restore Mysql All Database

If we want to restore all database, please run the following command to restore.

mysql -u username -p < backup_file.sql

Backup Restore Mysql Include Store Procedure

This is additional, if we want to backup and restore mysql with include store procedure SPR.

mysqldump -u username -p --routines database_name > backup_file.sql

And to restore, run this command below.

mysql -u username -p --routines database_name < backup_file.sql

That is simply article about how to backup and restore mysql from command line cli. Maybe usefull.

habibzain Just husband, father and enthusiastic men about System Administration. Love to write short article about it. Perhaps can help and be useful for others.

Ispconfig Nginx Directives Laravel

In a typical Laravel installation, the public folder contains all of the publicly accessible files for the application. This includes the index.php file, which...
habibzain
47 sec read

How to Hide Version nginx

Nginx is a popular web server that powers many websites and applications. However, by default, nginx reveals its version number in the HTTP response...
habibzain
1 min read

How to Install SSH in Windows 10/11

SSH (Secure Shell) is a protocol that allows us to securely remote servers and devices over a network. SSH can be used for various...
habibzain
1 min read

Leave a Reply

Your email address will not be published. Required fields are marked *

Never miss a story from us, get weekly updates in your inbox