Get the App
SLTechnology News&Howtos  ›  Database  › 

The method of using Command Line to back up MySQL Database in Linux

Shulou Source: shulou.com Published: 2022-06-01 18:35:26 09月18日 Update

The following brings you about the method of using the command line to back up the MySQL database in Linux. I believe you must have read similar articles. What's the difference between what we bring to everyone? Let's take a look at the body. I'm sure you'll get something after reading the method of using the command line to back up the MySQL database in Linux.

How to export a MySQL database using the command line in Debian or Ubuntu

The command to export the database in mysql using the command line is mysqldump. The mysqldump command should come with any installation of mysql or mariadb

The format to use it is as follows:

Mysqldump-u username-p database_name > output_file.sql

For example, if you have a mysql user name named "testuser" and a database named "sample_database", you can back up the mysql database "sample_database" using the following command.

Mysqldump-u testuser-p sample_database > output_file.sql

Note that I call the output sample_database_output.sql, but you can name it as you like. ) after entering the above command, you will be prompted for the user's MySQL password.

The following screenshot shows what the above command should look like:

An example of how to back up a mysql database in Debian or Ubuntu.

The output file will have SQL data, but you can actually name the file as needed, so the file extension does not have to end with .sql. It can end with .txt or any way you like.

You can see what the sample output SQL file should look like here. Through the link I mentioned, I output a database called mysql, which exists in every mysql installation.

Do you think it is what you want about the above method of using the command line to back up MySQL database in Linux? If you want to know more about it, you can continue to follow our industry information section.

Tags: Commands data database backup file output method appearance user example input different above below content can make actually password screen Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information Shulou Tech Info MySQL MariaDB Shulou Technology