mysql報錯 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.host' doesn't exist
阿新 • • 發佈:2019-04-25
CentOS 6.5 下安裝配置 mysql
使用yum安裝,具體過程參見最下邊的參考文章。
安裝之後啟動失敗:
[root@localhost ~]# service mysqld start
Starting mysqld: [ FAILD ]
啟動失敗,查看出錯原因(記錄在/var/log/mysqld.log 檔案裡):
[root@localhost ~]# cat /var/log/mysqld.log 190425 13:56:00 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql /usr/libexec/mysqld: Table 'mysql.plugin' doesn't exist 190425 13:56:00 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it. 190425 13:56:00 InnoDB: Initializing buffer pool, size = 8.0M 190425 13:56:00 InnoDB: Completed initialization of buffer pool InnoDB: Error: log file ./ib_logfile0 is of different size 0 50331648 bytes InnoDB: than specified in the .cnf file 0 5242880 bytes! 190425 13:56:00 [ERROR] Plugin 'InnoDB' init function returned error. 190425 13:56:00 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed. 190425 13:56:00 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.host' doesn't exist 190425 13:56:00 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended 190425 13:58:07 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql 190425 13:58:07 InnoDB: Initializing buffer pool, size = 8.0M 190425 13:58:07 InnoDB: Completed initialization of buffer pool InnoDB: Error: log file ./ib_logfile0 is of different size 0 50331648 bytes InnoDB: than specified in the .cnf file 0 5242880 bytes! 190425 13:58:07 [ERROR] Plugin 'InnoDB' init function returned error. 190425 13:58:07 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed. 190425 13:58:07 [Note] Event Scheduler: Loaded 0 events 190425 13:58:07 [Note] /usr/libexec/mysqld: ready for connections. Version: '5.1.73' socket: '/var/lib/mysql/mysql.sock' port: 3306 Source distribution (這裡的提示最後幾行是解決之後啟動了軟體然後埠開放了。與前邊報錯顯示在同一檔案裡了。)
解決方法:
mysql_install_db
(參考自文章2。)
# 注意!(這裡的提示是解決之後的,剛安裝完mysql時啟動是報錯的,OK那裡是FAILD)
# 另,mysql預設不推薦用root使用者來啟動軟體。正常情況下用root啟動會有提示或報錯,這裡沒有報錯就啟動了。需要注意一下。
[root@localhost ~]# service mysqld start
Starting mysqld: [ OK ]
參考資料:
1、Linux學習之CentOS(十三)--CentOS6.4下Mysql資料庫的安裝與配置
2、mysql報錯Fatal error: Can't open and lock privilege tables: Table 'mysql.ho