Preface:
Sometimes, when we want to back up the database, since GTID reason, the export system libraries, import databases of other environmental again, will go wrong. So, we need to drain some of the system library, excluding the impact GTID for database migration.
method:
Actually very simple, the following libraries are discharged to go like:
mysql
Information_schema
database
performance_schema
sys
You can use the following script:
#!/bin/bash
user=root
password=123456
data_path=/test/db_without_sys
mysql -e "show databases;" -u $user -p $password| grep -Ev "Database|information_schema|performance_schema|mysql|sys"|xargs mysqldump -uroot -p$password --set-gtid-purged=OFF --triggers --routines --events --databases > $data_path/all`date +\%Y\%m\%d\%H\%M`.sql
It can be.