来自旧硬盘系统的 mysql datadir 无法启动

标签 mysql linux ubuntu fedora

我正在尝试将 mysql 数据库从装有 fedora9(不再启动)的旧驱动器迁移到 ubuntu 16.04 服务器。

我把旧系统的/var/lib/mysql文件夹复制到新系统的/testdb/mysql中。

我将所有者更改为 mysql:mysql 到新文件夹并将 my.conf 的 datadir 更新到这个新文件夹,但是 mysql 服务器不再启动。我收到以下错误:

170625 12:44:37 [Warning] Using unique option prefix myisam-recover instead of myisam-recover-options is deprecated and will be removed in a future release. Please use the full name instead.
170625 12:44:37 [Note] Plugin 'FEDERATED' is disabled.
/usr/sbin/mysqld: Table 'mysql.plugin' doesn't exist
170625 12:44:37 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
170625 12:44:37 InnoDB: The InnoDB memory heap is disabled
170625 12:44:37 InnoDB: Mutexes and rw_locks use GCC atomic builtins
170625 12:44:37 InnoDB: Compressed tables use zlib 1.2.8
170625 12:44:37 InnoDB: Using Linux native AIO
170625 12:44:37 InnoDB: Initializing buffer pool, size = 128.0M
170625 12:44:37 InnoDB: Completed initialization of buffer pool
170625 12:44:37  InnoDB: Operating system error number 13 in a file operation.
InnoDB: The error means mysqld does not have the access rights to
InnoDB: the directory.
InnoDB: File name ./ibdata1
InnoDB: File operation call: 'open'.
InnoDB: Cannot continue operation.
170625 12:44:38 [Warning] Using unique option prefix myisam-recover instead of myisam-recover-options is deprecated and will be removed in a future release. Please use the full name instead.
170625 12:44:38 [Note] Plugin 'FEDERATED' is disabled.
/usr/sbin/mysqld: Table 'mysql.plugin' doesn't exist
170625 12:44:38 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
170625 12:44:38 InnoDB: The InnoDB memory heap is disabled
170625 12:44:38 InnoDB: Mutexes and rw_locks use GCC atomic builtins
170625 12:44:38 InnoDB: Compressed tables use zlib 1.2.8
170625 12:44:38 InnoDB: Using Linux native AIO
170625 12:44:38 InnoDB: Initializing buffer pool, size = 128.0M
170625 12:44:38 InnoDB: Completed initialization of buffer pool
170625 12:44:38  InnoDB: Operating system error number 13 in a file operation.
InnoDB: The error means mysqld does not have the access rights to
InnoDB: the directory.
InnoDB: File name ./ibdata1
InnoDB: File operation call: 'open'.
InnoDB: Cannot continue operation.
170625 12:44:38 [Warning] Using unique option prefix myisam-recover instead of myisam-recover-options is deprecated and will be removed in a future release. Please use the full name instead.
170625 12:44:38 [Note] Plugin 'FEDERATED' is disabled.
/usr/sbin/mysqld: Table 'mysql.plugin' doesn't exist
170625 12:44:38 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
170625 12:44:38 InnoDB: The InnoDB memory heap is disabled
170625 12:44:38 InnoDB: Mutexes and rw_locks use GCC atomic builtins
170625 12:44:38 InnoDB: Compressed tables use zlib 1.2.8
170625 12:44:38 InnoDB: Using Linux native AIO
170625 12:44:38 InnoDB: Initializing buffer pool, size = 128.0M
170625 12:44:38 InnoDB: Completed initialization of buffer pool
170625 12:44:38  InnoDB: Operating system error number 13 in a file operation.
InnoDB: The error means mysqld does not have the access rights to
InnoDB: the directory.
InnoDB: File name ./ibdata1
InnoDB: File operation call: 'open'.
InnoDB: Cannot continue operation.

我尝试更改所有权限,甚至更改所有文件的 777(只是为了尝试),但总是得到相同的结果。

如何恢复数据库?

最佳答案

我终于找到了恢复表的方法,它没有从 my.conf 更改数据目录(它没有用,即使复制默认数据库的内容也能正常工作),我复制了我想要的文件夹恢复到默认数据目录,覆盖除 mysql.sock 和 mysql 文件夹之外的所有文件。 然后我启动了 mysql 服务器并且它可以工作,但是一些表应该用

mysqlcheck --repair --all-databases -u root -p 

现在一切正常

关于来自旧硬盘系统的 mysql datadir 无法启动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44750086/

相关文章:

mysql - 在 mysql 中选择新用户和返回用户的总票数

python - Cron 作业生成 crontab.txt : not found

linux - 为什么Linux驱动需要编译?

linux - 如何在 GNU linux 上按模式拆分文件? (split 命令在 GNU 上不像在 BSD 上那样有 -p 标志)

python - Django:导入错误:没有名为 social.apps.django_app 的模块

linux - ls 命令忽略特定目录 [bash]

php - MySQL 分组依据或排序依据

c# - 在下拉列表上绑定(bind)数据

java - 在Java中的prepered语句中将参数传递给子查询的外表

multithreading - Pytorch 使用了太多资源