MySQL database backup and recovery method
Novices often ask me how to back up the database.Here are 3 ways to back up the database:
(1) Back up the database file
Each database and data table in MySQL corresponds to a directory in the file system and a file under it.
The storage directory of database files under Linux is generally/var/lib/mysql.Under Windows, this directory depends on the MySQL installation path.The technicians of DiaHosting usually install it in D:serversoftmysqlNext.
For example, if there is a database named bbs, the bbs database file will be stored under/var/lib/mysql/bbs (linux) or D:serversoftmysqlbbs (Windows).
Before backing up files, you need to stop the MySQL service, and then copy the database directory.
When restoring a data database, you need to create a database (not necessarily the same name), and then copy the backup file (note, not a directory) to the corresponding MySQL database directory.
When using this method to back up and restore the database, the new and old MySQL versions must be consistent, otherwise errors may occur.
(2) Use command line tools
Backup database:
mysqldump
6 Comments