1、when using LOCK TABLES
mysqldump -u root -p 库名称 > 文件名称.sql
Enter password:
mysqldump: Got error: 1044: Access denied for user 'root'@'localhost' to database 'xxxxxx库名称' when using LOCK TABLES
解决 加 --single-transaction
mysqldump -u root -p --single-transaction --databases 库名称 > 文件名称.sql
2、错误 'show_compatibility_56' (3167)
Enter password:
mysqldump: Couldn't execute 'SELECT /*!40001 SQL_NO_CACHE */ * FROM `GLOBAL_STATUS`': The 'INFORMATION_SCHEMA.GLOBAL_STATUS' feature is disabled; see the documentation for 'show_compatibility_56' (3167)
原因:
从mysql5.7.6开始information_schema.global_status已经开始被舍弃,为了兼容性,此时需要打开 show_compatibility_56
解决: 打开 show_compatibility_56
mysql -u root -p
mysql> show version #查看版本
select version();
+------------+
| version() |
+------------+
| 5.7.32-log |
+------------+
1 row in set (0.00 sec)
mysql> show variables like '%show_compatibility_56%'; #查看开关
+-----------------------+-------+
| Variable_name | Value |
+-----------------------+-------+
| show_compatibility_56 | OFF |
+-----------------------+-------+
1 row in set (0.00 sec)
mysql> set global show_compatibility_56=on; #打开
Query OK, 0 rows affected (0.00 sec)
mysql> show variables like '%show_compatibility_56%'; #查看
+-----------------------+-------+
| Variable_name | Value |
+-----------------------+-------+
| show_compatibility_56 | ON |
+-----------------------+-------+
1 row in set (0.00 sec)
3.导出数据操作:
[root@database01_2b op]# mysqldump -u root -p --single-transaction --databases 库名称 > 文件名称.sql
Enter password: