In depth analysis of the backup and restore of MySQL database under Linux
- 2020-06-01 11:10:13
- OfStack
In-depth analysis of MySQL database backup and restore under Linux
1. Backup
[root@localhost ~]# cd /var/lib/mysql (go to the MySQL library directory and adjust the directory according to your MySQL installation)
[root@localhost mysql]# mysqldump -u root -p voice
>
voice.sql, just enter your password.
2. The reduction
Method 1:
Enter and enter your password to enter MySQL's console "mysql"
>
", the same as 1.2 reduction.
Method 2:
[root@localhost ~]# cd /var/lib/mysql (go to the MySQL library directory and adjust the directory according to your MySQL installation)
[root@localhost mysql]# mysql -u root -p voice
<
voice.sql, just enter your password.
mysqldump: Got error: 1016 when using LOCK TABLES
hitidea is a database with a lot of data tables (Wordpress MU). After searching for 1, we found that the problem could be solved by adding the word "lock-tables =false" to mysqldump.
mysqldump -uroot -p123456 sq_mvclub --lock-tables=false > /home/bak/35.sql