提问人:togarha 提问时间:6/26/2017 更新时间:6/28/2017 访问量:141
旧硬盘系统的MySQL DataDir无法启动
mysql datadir from old hard drive system does not boot
问:
我正在尝试将 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 更改为所有文件(只是为了尝试),但总是有相同的结果。
如何恢复数据库?
答:
0赞
togarha
6/28/2017
#1
我终于找到了恢复表的方法,它没有从 my.conf 更改 datadir(它不起作用,即使复制了工作正常的默认数据库的内容),我将要恢复的文件夹复制到默认 datadir,覆盖除 mysql.sock 和 mysql 文件夹之外的所有文件。 然后我启动了mysql服务器,它可以工作,但是有些表需要修复
mysqlcheck --repair --all-databases -u root -p
现在一切正常
评论
-rwxrwxrwx 1 mysql mysql 18874368 jun 25 12:22 ibdata1
/var/lib/mysql
sudo mkdir /var/liv
root:root
/var/lib
sudo cp -rp /var/lib/mysql /var/liv
/etc/mysql/my.cnf
datadir = /var/liv/mysql