命令行

命令行

恢复备份后服务器无法启动。

命令行

tar -izxf /var/bak/db/2013-11-16-2300_mysql.tar.gz -C /var/bak/db_import
innobackupex --defaults-file=/var/ini/my.cnf --use-memory=1G --apply-log /var/bak/db_import
service mysql stop
mv /var/lib/mysql /var/lib/mysql-old
mkdir /var/lib/mysql
innobackupex --defaults-file=/var/ini/my.cnf --copy-back /var/bak/db_import
chown -R mysql:mysql /var/lib/mysql
/usr/local/mysql/scripts/mysql_install_db --user=mysql --datadir=/var/lib/mysql
service mysql start

错误日志

131112 02:00:54 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
2013-11-12 02:00:55 0 [Warning] Using unique option prefix key_buffer instead of key_buffer_size is deprecated and will be removed in a future release. Please use the full name instead.
2013-11-12 02:00:55 0 [Warning] Using unique option prefix key_buffer instead of key_buffer_size is deprecated and will be removed in a future release. Please use the full name instead.
2013-11-12 02:00:55 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2013-11-12 02:00:55 19706 [Warning] Using pre 5.5 semantics to load error messages from /opt/mysql/server-5.6/share/english/.
2013-11-12 02:00:55 19706 [Warning] If this is not intended, refer to the documentation for valid usage of --lc-messages-dir and --language parameters.
2013-11-12 02:00:55 19706 [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.
2013-11-12 02:00:55 19706 [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.
2013-11-12 02:00:55 19706 [Note] Plugin 'FEDERATED' is disabled.
/usr/local/mysql/bin/mysqld: Table 'mysql.plugin' doesn't exist
2013-11-12 02:00:55 19706 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
2013-11-12 02:00:55 19706 [Note] InnoDB: The InnoDB memory heap is disabled
2013-11-12 02:00:55 19706 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2013-11-12 02:00:55 19706 [Note] InnoDB: Compressed tables use zlib 1.2.3
2013-11-12 02:00:55 19706 [Note] InnoDB: Using Linux native AIO
2013-11-12 02:00:55 19706 [Note] InnoDB: Not using CPU crc32 instructions
2013-11-12 02:00:55 19706 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2013-11-12 02:00:55 19706 [Note] InnoDB: Completed initialization of buffer pool
2013-11-12 02:00:55 19706 [Note] InnoDB: Highest supported file format is Barracuda.
2013-11-12 02:00:55 19706 [Note] InnoDB: Log scan progressed past the checkpoint lsn 10944663
2013-11-12 02:00:55 19706 [Note] InnoDB: Database was not shutdown normally!
2013-11-12 02:00:55 19706 [Note] InnoDB: Starting crash recovery.
2013-11-12 02:00:55 19706 [Note] InnoDB: Reading tablespace information from the .ibd files...
2013-11-12 02:00:55 19706 [Note] InnoDB: Restoring possible half-written data pages 
2013-11-12 02:00:55 19706 [Note] InnoDB: from the doublewrite buffer...
InnoDB: Doing recovery: scanned up to log sequence number 10944683
2013-11-12 02:00:55 19706 [Note] InnoDB: 128 rollback segment(s) are active.
2013-11-12 02:00:55 19706 [Note] InnoDB: Waiting for purge to start
2013-11-12 02:00:55 19706 [Note] InnoDB: 5.6.14 started; log sequence number 10944683
2013-11-12 02:00:55 19706 [Note] Server hostname (bind-address): '127.0.0.1'; port: 3306
2013-11-12 02:00:55 19706 [Note]   - '127.0.0.1' resolves to '127.0.0.1';
2013-11-12 02:00:55 19706 [Note] Server socket created on IP: '127.0.0.1'.
2013-11-12 02:00:55 19706 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.user' doesn't exist
131112 02:00:55 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended

答案1

首先,mysql_upgrade:未找到命令。这是基本的 Linux/UNIX PATH 行为。如果您运行,echo $PATH您将看到没有列出“/opt/mysql/server-5.6/bin”或“。”。与 Windows 不同,您所在目录中的命令不会通过简单地键入名称来执行。您需要指定完整路径或将路径添加到 PATH 环境变量中。您可以通过进入“/opt/mysql/server-5.6/bin”并运行以下命令来测试这一点:

PATH=$PATH:/opt/mysql/server-5.6/bin mysql_upgrade./mysql_upgrade

对于您实际的 MySQL 问题,日志清楚地表明您在 mysql 模式中缺少多个表。很可能您缺少整个 mysql 模式,因为它首先没有备份。在这种情况下,我认为 mysql_upgrade 不会为您修复它,您需要有模式才能“升级”。

查找名为的脚本mysql_install_db并运行该脚本以创建初始表和/或确保您也备份该模式。

相关内容