mysql问题#1146 - Table 'xxx.xxxxx' doesn't exist

本文分享了一次因误删MySQL重要文件导致数据库无法正常使用的问题及其解决过程。通过替换ibdata1文件,成功恢复了所有数据。

这次出现这个问题是由于博主手yang,误删mysql重要文件所致的.
在重装mysql后,进入mysql navicat发现之前的数据库中的表都无法使用了,尴尬探索之际发现,这个是由于重新安装mysql,导致其ibdata1更新无法导入data数据包中的数据库。

  • 所幸博主比较机灵,在重装mysql之前对其data包有进行备份,hahahahahahahaha………*
  • 在博主替换了D:\ProgramData\MySQL\MySQL Server 5.1\data中的ibdata1文件后,一切步入正轨,所有的数据又可以重新使用了

  • 建议不要象博主这样手贱

  • 如果你也象博主有手yang,爱清理电脑垃圾的习惯,建议要常备份数据库,及重要文件,不要问博主是谁·,我姓雷*
  • 重点是ibdata1文件,在本机中的路径为D:\ProgramData\MySQL\MySQL Server 5.1\data
spring: datasource: dynamic: enable: true druid: # JDBC 配置(驱动类自动从url的mysql识别,数据源类型自动识别) core: url: jdbc:mysql://xxx.xxx.x.xxx.:xxxx/sss-framework?useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true&useSSL=false&&zeroDateTimeBehavior=convertToNull username: xxx password: xxxxx driver-class-name: com.mysql.jdbc.Driver log: url: jdbc:mysql://xxx.xxx.x.xxx.:xxxx/log-center?useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true&useSSL=false username: xxx password: xxxxx driver-class-name: com.mysql.jdbc.Driver dc: # 目标数据源(j1dc-data-center 库) url: jdbc:mysql://xxx.xxx.x.xxx.:xxxx/j1dc-data-center?useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true&useSSL=false&zeroDateTimeBehavior=convertToNull username: xxx password: xxxxx driver-class-name: com.mysql.jdbc.Driver #连接池配置(通常来说,只需要修改initialSize、minIdle、maxActive initial-size: 1 max-active: 20 min-idle: 1 # 配置获取连接等待超时的时间 max-wait: 60000 #打开PSCache,并且指定每个连接上PSCache的大小 pool-prepared-statements: true max-pool-prepared-statement-per-connection-size: 20 validation-query: SELECT &#39;x&#39; test-on-borrow: false test-on-return: false test-while-idle: true #配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 time-between-eviction-runs-millis: 60000 #配置一个连接在池中最小生存的时间,单位是毫秒 min-evictable-idle-time-millis: 300000 filters: stat,wall # WebStatFilter配置,说明请参考Druid Wiki,配置_配置WebStatFilter #是否启用StatFilter默认值true web-stat-filter.enabled: true web-stat-filter.url-pattern: /* web-stat-filter.exclusions: "*.js , *.gif ,*.jpg ,*.png ,*.css ,*.ico , /druid/*" web-stat-filter.session-stat-max-count: 1000 web-stat-filter.profile-enable: true # StatViewServlet配置 #展示Druid的统计信息,StatViewServlet的用途包括:1.提供监控信息展示的html页面2.提供监控信息的JSON API #是否启用StatViewServlet默认值true stat-view-servlet.enabled: true #根据配置中的url-pattern来访问内置监控页面,如果是上面的配置,内置监控页面的首页是/druid/index.html例如: #http://110.76.43.235:9000/druid/index.html #http://110.76.43.235:8080/mini-web/druid/index.html stat-view-servlet.url-pattern: /druid/* #允许清空统计数据 stat-view-servlet.reset-enable: true stat-view-servlet.login-username: admin stat-view-servlet.login-password: admin #StatViewSerlvet展示出来的监控信息比较敏感,是系统运行的内部情况,如果你需要做访问控制,可以配置allow和deny这两个参数 #deny优先于allow,如果在deny列表中,就算在allow列表中,也会被拒绝。如果allow没有配置或者为空,则允许所有访问 #配置的格式 #<IP> #或者<IP>/<SUB_NET_MASK_size>其中128.242.127.1/24 #24表示,前面24位是子网掩码,比对的时候,前面24位相同就匹配,不支持IPV6。 #stat-view-servlet.allow= #stat-view-servlet.deny=128.242.127.1/24,128.242.128.1 # Spring监控配置,说明请参考Druid Github Wiki,配置_Druid和Spring关联监控配置 #aop-patterns= # Spring监控AOP切入点,如x.y.z.service.*,配置多个英文逗号分隔 ################### mysq end ########################## # zipkin: # base-url: http://127.0.0.1:11008 redis: ################### redis 单机版 start ########################## host: 192.168.1.226 port: 6379 timeout: 6000 database: 2 lettuce: pool: max-active: 10 # 连接池最大连接数(使用负值表示没有限制),如果赋值为-1,则表示不限制;如果pool已经分配了maxActive个jedis实例,则此时pool的状态为exhausted(耗尽) max-idle: 8 # 连接池中的最大空闲连接 ,默认值也是8 max-wait: 100 # # 等待可用连接的最大时间,单位毫秒,默认值为-1,表示永不超时。如果超过等待时间,则直接抛出JedisConnectionException min-idle: 2 # 连接池中的最小空闲连接 ,默认值也是0 shutdown-timeout: 100ms ################### redis 单机版 end ########################## #mybatis: mybatis-plus: configuration: log-impl: org.apache.ibatis.logging.stdout.StdOutImpl config-location: classpath:mybatis.cfg.xml mapper-locations: classpath*:com/open/**/dao/*.xml security: oauth2: ignored: "/minvideo/**,/tplatformuser/getUserIdCardAndName,/tmedicaldoctor/app/**,\ /tmedicaldoctor/getDoctorStatus,/tmedicaldoctor/list,\ /sms/tencent/callback,/app/forgetPwd,/app/registe,/wechat/login,/app/login,/newsinfo/search,\ /newsinfo/list,/newsinfo/slideshow,/newsinfo/selectAll,/doc.html,/document.html,/statistics/**,\ /tmedicaldoctor/app/verifyCode/login,/noticemessage/getNoticeMessageList" token: store: type: redis #设置最大超时时间 ribbon: ServerListRefreshInterval: 10 #刷新服务列表源的间隔时间 OkToRetryOnAllOperations: true MaxAutoRetries: 1 MaxAutoRetriesNextServer: 1 ReadTimeout: 16000 ConnectTimeout: 16000 #设置最大容错超时时间 hystrix: command: default: execution: timeout: enabled: true isolation: thread: timeoutInMilliseconds: 16000 logging: level: com.open.capacity: INFO org.hibernate: INFO org.hibernate.type.descriptor.sql.BasicBinder: TRACE org.hibernate.type.descriptor.sql.BasicExtractor: TRACE # com.neusoft: DEBUG # com.netflix: DEBUG #用于心跳检测输出的日志 feign: client: config: default: loggerLevel: full ## 配合logging.level=trace debug用于开发调式日志 compression: request: enabled: true mine-types: text/xml,application/xml,application/json min-request-size: 2048 response: enabled: true #eureka client eureka: client: serviceUrl: defaultZone: http://127.0.0.1:1111/eureka #http://130.75.131.241:8761/eureka,http://130.75.131.248:8762/eureka registry-fetch-interval-seconds: 10 instance-info-replication-interval-seconds: 10 instance: prefer-ip-address: true instance-id: ${spring.application.name}:${spring.cloud.client.ip-address}:${spring.application.instance_id:${server.port}} #固定端口 # instance-id: ${spring.application.name}:${spring.cloud.client.ip-address}:${spring.application.instance_id:${randomServerPort.value[7000,7005]}} #随机端口 #instance-id: ${spring.application.name}:${docker.ipAddress}:${spring.application.instance_id:${server.port}} lease-renewal-interval-in-seconds: 5 #每隔几秒告诉eureka服务器我还存活,用于心跳检测 lease-expiration-duration-in-seconds: 10 #如果心跳检测一直没有发送,10秒后会从eureka服务器中将此服务剔除 status-page-url: http://${spring.cloud.client.ip-address}:${server.port}/document.html #固定端口 # status-page-url: http://${spring.cloud.client.ip-address}:${randomServerPort.value[7000,7005]}/document.html #随机端口 # 头像前缀url(补全之前的图片存数据库时仅存了路径问题) headPathPrefix: "http://xxxx.xxxx.cn/sss-web/download?filePath=" import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.Collections; import java.util.List; import java.util.Map; import java.util.stream.Collectors; @Service public class ChecksignInfoServiceImpl implements ChecksignInfoService { @Autowired private TMedicalDoctorDao tMedicalDoctorDao; @Autowired private ChecksignInfoDao checksignInfoDao; @Override public Result getChecksignInfo() { Long userId = AppLoginUser.getUser(); TMedicalDoctor doctor = tMedicalDoctorDao.getdoctorInfo(userId); if (null == doctor) { return Result.failed("该医生用户不存在"); } // 构建查询参数 Map<String, Object> params = new HashMap<>(2); params.put("doctorName", doctor.getFullName()); params.put("idCard", doctor.getIdCardNo()); // 获取医生团队信息并提取部门编码 String departCode = tMedicalDoctorDao.getDoctorTeamByDoctorId(params).stream() .filter(Objects::nonNull) .map(SinosoftTeam::getOrgCode) .findFirst() .orElse(null); if (departCode == null) { return Result.succeed(Collections.emptyList(), "未查询到相关团队信息"); } // 根据部门编码查询团队ID列表 List<Integer> teamIds = tMedicalDoctorDao.getDoctorTeamByDepartCode(departCode).stream() .filter(Objects::nonNull) .map(SinosoftTeam::getId) .collect(Collectors.toList()); if (teamIds.isEmpty()) { return Result.succeed(Collections.emptyList(), "未查询到相关团队ID"); } // 查询签约信息 List<SinosoftFamilySignInfo> signInfo = checksignInfoDao.getCheckInfo(teamIds); return Result.succeed(signInfo, "居民续约数据查询成功"); } } import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; import com.baomidou.dynamic.datasource.annotation.DS; import java.util.List; @Mapper @DS(value = "dc") public interface ChecksignInfoDao { @DS(value = "dc") List<SinosoftFamilySignInfo> getCheckInfo(@Param("teamIds") List<Integer> teamIds); } 希望在 类的 `getChecksignInfo` 方法中,只有调用 `checksignInfoDao.getCheckInfo(teamIds)` 时使用 `@DS(value = "dc")` 注解 `ChecksignInfoServiceImpl` 但是最终失败了 ### SQL: SELECT * FROM yw_task_sync__family_signinfo_temp t WHERE t.team_id IN ( ? , ? , ? , ? , ? , ? , ? ) AND t.audit_state = 0 AND t.notice_status = 0 AND DATE(t.gp_start) <= CURDATE() ORDER BY t.gp_start DESC LIMIT 15 ### Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table &#39;sss-framework.yw_task_sync__family_signinfo_temp&#39; doesn&#39;t exist
最新发布
11-08
### MySQL error 1146 Table &#39;mysql.desc&#39; doesn&#39;t exist 的解决方法 MySQL error 1146 表示尝试访问的某个系统表不存在。在用户遇到的 `Table &#39;mysql.desc&#39; doesn&#39;t exist` 错误中,`mysql.desc` 并不是 MySQL 的标准系统表,这通常意味着数据库结构存在异常,或者应用程序尝试访问了一个未创建或误配置的表。 #### 检查表是否存在 在执行任何操作之前,应首先确认目标表是否存在。可以通过以下 SQL 命令检查 `mysql` 数据库中的表列表: ```sql USE mysql; SHOW TABLES; ``` 如果 `desc` 表不在列表中,则说明该表确实不存在,需要进一步排查为何应用程序会尝试访问该表。 #### 分析应用程序逻辑 如果应用程序尝试访问 `mysql.desc` 表,但该表并不存在,可能是由于代码中存在拼写错误或误用了非标准表名。需要检查数据库访问逻辑,确保 SQL 查询中引用的表名与数据库中的实际表名一致。例如: ```sql SELECT * FROM mysql.desc; ``` 如果该语句报错,则说明表不存在,应根据实际需求创建表或更正表名[^1]。 #### 检查数据库初始化或升级过程 某些情况下,该错误可能出现在数据库初始化或版本升级过程中。如果 `mysql` 系统数据库中的关键表缺失(如 `user`、`proc`、`slow_log` 等),则可能是初始化脚本未正确执行。MySQL 5.7 及以上版本在初始化时会自动生成系统表,可以尝试重新初始化数据库: ```bash mysqld --initialize ``` 如果已存在数据目录,也可以使用 `--initialize-insecure` 选项进行初始化。初始化完成后,重启 MySQL 服务以确保系统表被正确加载[^3]。 #### 手动创建缺失的表 如果确认 `mysql.desc` 是应用程序所需的自定义表,但尚未创建,则应根据应用需求手动创建该表。例如: ```sql USE mysql; CREATE TABLE desc ( id INT PRIMARY KEY AUTO_INCREMENT, description TEXT ); ``` 创建完成后,再次执行相关 SQL 语句即可正常访问该表。 #### 恢复系统表 如果错误是由于其他系统表缺失(如 `mysql.user`、`mysql.proc`)引起的,则应参考 MySQL 官方文档中的恢复指南,使用备份数据恢复或重新初始化系统数据库。若没有备份,可尝试从相同版本的 MySQL 安装中复制系统表结构,但不建议直接复制数据文件,以避免不一致问题[^1]。 ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值