mysql出现表不存在错误如何解决
电脑重装系统后把原来的mysql data复制进去后大部分表是可以访问的,但是有几个表提示表不存在:
error: 1146: Table 'your_table' doesn't exist
这种情况就是要把原来mysql安装目录data里的 ibdata1 也要拷贝过去
INNODB是MYSQL数据库一种流行的数据库引擎,支持事务(行级),在企业级应用上成为可能。
ibdata用来储存文件的数据,而库名的文件夹里面的那些表文件只是结构而已,由于新版的mysql默认试innodb,所以ibdata1文件默认就存在了,少了这个文件有的数据表就会出错。
如果替换ibdata文件后发现启动报错:
[root@localhost data]# service mysql start Redirecting to /bin/systemctl start mysql.service Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" for details.
[root@localhost data]# systemctl status mysqld.service ● mysqld.service - LSB: start and stop MySQL Loaded: loaded (/etc/rc.d/init.d/mysqld; bad; vendor preset: disabled) Active: failed (Result: exit-code) since Tue 2019-01-08 18:12:43 CST; 8s ago Docs: man:systemd-sysv-generator(8) Process: 11815 ExecStop=/etc/rc.d/init.d/mysqld stop (code=exited, status=0/SUCCESS) Process: 13300 ExecStart=/etc/rc.d/init.d/mysqld start (code=exited, status=1/FAILURE) Jan 08 18:12:40 localhost.localdomain systemd[1]: Starting LSB: start and stop MySQL... Jan 08 18:12:43 localhost.localdomain mysqld[13300]: Starting MySQL... ERROR! The server quit without updating PID file (/www/server/data/localhost.localdomain.pid). Jan 08 18:12:43 localhost.localdomain systemd[1]: mysqld.service: control process exited, code=exited status=1 Jan 08 18:12:43 localhost.localdomain systemd[1]: Failed to start LSB: start and stop MySQL. Jan 08 18:12:43 localhost.localdomain systemd[1]: Unit mysqld.service entered failed state. Jan 08 18:12:43 localhost.localdomain systemd[1]: mysqld.service failed.
这时候先检查一下你的ibdata文件所属的用户和用户组是否正确,有可能是权限问题导致。
如果是数据表损坏请尝试修复表:
repair table tablename
推荐:MySQL教程
来源:PY学习网:原文地址:https://www.py.cn/article.html