Centos 7 上无法启动 Mysql

Centos 7 上无法启动 Mysql

我已在 Centos 7 (mysql-community-server) 上以 root 身份安装了 mysql。问题是我无法使用“service mysqld start”启动守护进程,它从不返回提示,即使我尝试使用另一个 ssh 会话,守护进程也不会启动。

这是我使用 tail“/var/log/mysqld.log”获得的输出:

2015-02-19 02:43:45 15299 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
2015-02-19 02:43:45 15299 [Note] InnoDB: Using atomics to ref count buffer pool pages
2015-02-19 02:43:45 15299 [Note] InnoDB: The InnoDB memory heap is disabled
2015-02-19 02:43:45 15299 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2015-02-19 02:43:45 15299 [Note] InnoDB: Memory barrier is not used
2015-02-19 02:43:45 15299 [Note] InnoDB: Compressed tables use zlib 1.2.3
2015-02-19 02:43:45 15299 [Note] InnoDB: Using Linux native AIO
2015-02-19 02:43:45 15299 [Note] InnoDB: Using CPU crc32 instructions
2015-02-19 02:43:45 15299 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2015-02-19 02:43:45 15299 [Note] InnoDB: Completed initialization of buffer pool
2015-02-19 02:43:45 15299 [Note] InnoDB: Highest supported file format is Barracuda.
2015-02-19 02:43:45 15299 [Note] InnoDB: Log scan progressed past the checkpoint lsn 49463
2015-02-19 02:43:45 15299 [Note] InnoDB: Database was not shutdown normally!
2015-02-19 02:43:45 15299 [Note] InnoDB: Starting crash recovery.
2015-02-19 02:43:45 15299 [Note] InnoDB: Reading tablespace information from the .ibd files...
2015-02-19 02:43:45 15299 [Note] InnoDB: Restoring possible half-written data pages
2015-02-19 02:43:45 15299 [Note] InnoDB: from the doublewrite buffer...
InnoDB: Doing recovery: scanned up to log sequence number 1600607
2015-02-19 02:43:45 15299 [Note] InnoDB: Starting an apply batch of log records to the database...
InnoDB: Progress in percent: 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
InnoDB: Apply batch completed
2015-02-19 02:43:45 15299 [Note] InnoDB: 128 rollback segment(s) are active.
2015-02-19 02:43:45 15299 [Note] InnoDB: Waiting for purge to start
2015-02-19 02:43:45 15299 [Note] InnoDB: 5.6.23 started; log sequence number 1600607
2015-02-19 02:43:45 15299 [Note] Server hostname (bind-address): '*'; port: 3306
2015-02-19 02:43:45 15299 [Note] IPv6 is available.
2015-02-19 02:43:45 15299 [Note]   - '::' resolves to '::';
2015-02-19 02:43:45 15299 [Note] Server socket created on IP: '::'.
2015-02-19 02:43:45 15299 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.user' doesn't exist
150219 02:43:45 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended

我尝试禁用 SELinux,但还是不起作用。我不知道发生了什么……

非常感谢您的帮助。谢谢

更新:/var/log/messages 的输出

Feb 19 01:52:15 localhost systemd: Started Network Manager Script Dispatcher Service.
Feb 19 01:53:51 localhost systemd: mysqld.service operation timed out. Stopping.
Feb 19 01:53:51 localhost systemd: Failed to start MySQL Community Server.
Feb 19 01:53:51 localhost systemd: Unit mysqld.service entered failed state.
Feb 19 01:53:51 localhost systemd: mysqld.service holdoff time over, scheduling restart.
Feb 19 01:53:51 localhost systemd: Stopping MySQL Community Server...
Feb 19 01:53:51 localhost systemd: Starting MySQL Community Server...
Feb 19 01:53:51 localhost mysqld_safe: 150219 01:53:51 mysqld_safe Logging to '/var/log/mysqld.log'.
Feb 19 01:53:51 localhost mysqld_safe: 150219 01:53:51 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
Feb 19 01:53:52 localhost mysqld_safe: 150219 01:53:52 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
Feb 19 01:55:57 localhost systemd: Created slice user-0.slice.
Feb 19 01:55:57 localhost systemd: Starting Session 23 of user root.
Feb 19 01:55:57 localhost systemd: Started Session 23 of user root.
Feb 19 01:55:57 localhost systemd-logind: New session 23 of user root.
Feb 19 01:55:57 localhost systemd: Starting Session 24 of user root.
Feb 19 01:55:57 localhost systemd: Started Session 24 of user root.
Feb 19 01:55:57 localhost systemd-logind: New session 24 of user root.

答案1

最后我找到了解决方案:

我用了:

mysql_install_db --user=mysql -ldata=/var/lib/mysql

进而

/usr/bin/mysql_secure_installation (it never worked before)

它确实发挥了作用!

相关内容