mysql 旧硬盘系统的数据目录无法启动

mysql datadir from old hard drive system does not boot

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

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

我将所有者更改为 mysql:mysql 到新文件夹并将 my.conf 的数据目录更新到这个新文件夹,但是 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 

现在一切正常