LAMP的mariadb无法启动

今天突然无法启动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

©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 204,189评论 6 478
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 85,577评论 2 381
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 150,857评论 0 337
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,703评论 1 276
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 63,705评论 5 366
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,620评论 1 281
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 37,995评论 3 396
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,656评论 0 258
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 40,898评论 1 298
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,639评论 2 321
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,720评论 1 330
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,395评论 4 319
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 38,982评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,953评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,195评论 1 260
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 44,907评论 2 349
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,472评论 2 342

推荐阅读更多精彩内容