今天突然无法启动mariadb
以为是linux权限问题,开始执行了开启全部权限:还是无法启动。
如下:
[root@VM_82_192_centos ~]#
[root@VM_82_192_centos ~]# chmod -R 777 /var/lib/mysql
[root@VM_82_192_centos ~]# systemctl start mariadb.service
Job for mariadb.service failed because the control process exited with error code. See "systemctl status mariadb.service" and "journalctl -xe" for details.
[root@VM_82_192_centos ~]# journalctl -xe
--
-- Unit session-26.scope has finished starting up.
--
-- The start-up result is done.
Feb 01 10:02:01 VM_82_192_centos CROND[3893]: (root) CMD (/usr/local/qcloud/stargate/admin/start.sh > /dev/null 2>&1 &)
Feb 01 10:02:01 VM_82_192_centos systemd[1]: Starting Session 26 of user root.
-- Subject: Unit session-26.scope has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit session-26.scope has begun starting up.
Feb 01 10:03:01 VM_82_192_centos systemd[1]: Started Session 27 of user root.
-- Subject: Unit session-27.scope has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit session-27.scope has finished starting up.
--
-- The start-up result is done.
Feb 01 10:03:01 VM_82_192_centos systemd[1]: Starting Session 27 of user root.
-- Subject: Unit session-27.scope has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit session-27.scope has begun starting up.
Feb 01 10:03:01 VM_82_192_centos CROND[3935]: (root) CMD (/usr/local/qcloud/stargate/admin/start.sh > /dev/null 2>&1 &)
Feb 01 10:03:19 VM_82_192_centos polkitd[467]: Registered Authentication Agent for unix-process:3963:138891 (system bus name :1.79 [
Feb 01 10:03:19 VM_82_192_centos systemd[1]: Starting MariaDB database server...
-- Subject: Unit mariadb.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit mariadb.service has begun starting up.
Feb 01 10:03:19 VM_82_192_centos mariadb-prepare-db-dir[3969]: Database MariaDB is probably initialized in /var/lib/mysql already, n
Feb 01 10:03:19 VM_82_192_centos mariadb-prepare-db-dir[3969]: If this is not the case, make sure the /var/lib/mysql is empty before
Feb 01 10:03:19 VM_82_192_centos mysqld_safe[3999]: 180201 10:03:19 mysqld_safe Logging to '/var/log/mariadb/mariadb.log'.
Feb 01 10:03:19 VM_82_192_centos mysqld_safe[3999]: 180201 10:03:19 mysqld_safe Starting mysqld daemon with databases from /var/lib/
Feb 01 10:03:21 VM_82_192_centos systemd[1]: mariadb.service: control process exited, code=exited status=1
Feb 01 10:03:21 VM_82_192_centos polkitd[467]: Unregistered Authentication Agent for unix-process:3963:138891 (system bus name :1.79
Feb 01 10:03:21 VM_82_192_centos systemd[1]: Failed to start MariaDB database server.
-- Subject: Unit mariadb.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit mariadb.service has failed.
--
-- The result is failed.
Feb 01 10:03:21 VM_82_192_centos systemd[1]: Unit mariadb.service entered failed state.
Feb 01 10:03:21 VM_82_192_centos systemd[1]: mariadb.service failed.
以上报错不准确:应该直接去mariadb错误日志查看。mysql对应的是error.log
[root@VM_82_192_centos ~]# tail -n 30 /var/log/mariadb/mariadb.log
180201 9:48:45 InnoDB: highest supported file format is Barracuda.
InnoDB: The log sequence number in ibdata files does not match
InnoDB: the log sequence number in the ib_logfiles!
InnoDB: Restoring possible half-written data pages from the doublewrite buffer...
180201 9:48:45 InnoDB: Waiting for the background threads to start
180201 9:48:46 Percona XtraDB (http://www.percona.com) 5.5.52-MariaDB-38.3 started; log sequence number 16782537
180201 9:48:46 [Note] Plugin 'FEEDBACK' is disabled.
180201 9:48:46 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
180201 9:48:46 [Note] Server socket created on IP: '0.0.0.0'.
180201 9:48:46 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.host' doesn't exist
180201 09:48:46 mysqld_safe mysqld from pid file /var/run/mariadb/mariadb.pid ended
180201 10:03:19 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
180201 10:03:19 [Note] /usr/libexec/mysqld (mysqld 5.5.56-MariaDB) starting as process 4163 ...
180201 10:03:19 InnoDB: The InnoDB memory heap is disabled
180201 10:03:19 InnoDB: Mutexes and rw_locks use GCC atomic builtins
180201 10:03:19 InnoDB: Compressed tables use zlib 1.2.7
180201 10:03:19 InnoDB: Using Linux native AIO
查看对应的ERROR:
Can't open and lock privilege tables: Table 'mysql.host' doesn't exist
报错:
Fatal error: Can't open and lock privilege tables: Table 'mysql.host' doesn'
经过查阅资料得知。要敲如下命令解决:
mysql_install_db --user=mysql --datadir=/var/lib/mysql
[root@VM_82_192_centos ~]# systemctl start mariadb.service
[root@VM_82_192_centos ~]# systemctl status mariadb.service
● mariadb.service - MariaDB database server
Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
Active: active (running) since Thu 2018-02-01 10:13:45 CST; 9s ago
Process: 4919 ExecStartPost=/usr/libexec/mariadb-wait-ready $MAINPID (code=exited, status=0/SUCCESS)
Process: 4888 ExecStartPre=/usr/libexec/mariadb-prepare-db-dir %n (code=exited, status=0/SUCCESS)
Main PID: 4918 (mysqld_safe)
CGroup: /system.slice/mariadb.service
├─4918 /bin/sh /usr/bin/mysqld_safe --basedir=/usr
└─5082 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --log-error=/v...
OK完成,如果重启mysql还是不行试下单独的命令:mysql_install_db