Xiaohan Practical Operation - Mysql database backup and recovery and security configuration

Mysql database backup:

       The mysqldump command backs up the data in the database into a text file. The structure of the table and the data in the table will be stored in the generated text file.

The working principle of the        mysqldump command is very simple. It first finds out the structure of the table to be backed up, and then generates a CREATE statement in the text file. Then, convert all the records in the table into an INSERT statement. Then through these statements, you can create tables and insert data.

example:

  • Here I back up the mysql library to /opt
[root@hya ~]# mysqldump -uroot -pxiaohan123 mysql > /opt/xiaohan.sql
[root@hya ~]# ll /opt/
总用量 504
-rw-r--r--. 1 root root 514780 6月  29 16:37 xiaohan.sql
  • I delete the mysql database in the database and restore it
MariaDB [(none)]> drop database mysql;  ##删除
Query OK, 24 rows affected, 2 warnings (0.01 sec)

MariaDB [(none)]> create database mysql;
MariaDB [(none)]> use mysql;
MariaDB [(none)]> source /opt/xiaohan.sql ##恢复
Query OK, 0 rows

Guess you like

Origin blog.csdn.net/yeyslspi59/article/details/108608591