MySQL 导出数据库,出现 “mysqldump: Got error: 1146”

出现场景

在 cmd 导出数据库时:

mysqldump -hlocalhost -uroot -p student_db > C:student_db.sql

出现:

mysqldump: Got error: 1146: Table 'student_db.student' doesn't exist when using LOCK TABLES

解决过程

网上说锁定所有表即可解决,即:--lock-all-tables,-x
mysqldump -hlocalhost -uroot -p -x student_db > C:student_db.sql
然而我的情况并没有解决。

查看出现问题的数据表:

use student_db;
show tables;
-- student 存在

select * from student;
show create table student;
-- 上面两个都提示:ERROR 1146 (42S02): Table 'student_db.student' doesn't exist

结论

重启 MySQL,再次进入时 OK。

原文地址:https://www.cnblogs.com/blueherb/p/10531934.html