問(wèn)題概述
關(guān)于這個(gè),博主是在遷移數(shù)據(jù)庫(kù)的時(shí)候遇到的,
為了緊貼單位的發(fā)展戰(zhàn)略及發(fā)展文化方針,給單位培養(yǎng)人才,先大膽的讓同事先嘗試著操作,最后出現(xiàn)問(wèn)題了,博主就出場(chǎng)了,
查看事件內(nèi)容提示:
“?Fatal error: Can‘t open and lock privilege tables: Table ‘mysql.user‘ doesn‘t exis ”
Debug的錯(cuò)誤日志,如下圖:
具體信息如下:
2022-04-22 14:18:09+08:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.6.51-1debian9 started.
2022-04-22 14:18:10+08:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2022-04-22 14:18:10+08:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.6.51-1debian9 started.
2022-04-22 14:18:10 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2022-04-22 14:18:10 0 [Note] mysqld (mysqld 5.6.51) starting as process 1 ...
2022-04-22 14:18:10 1 [Note] Plugin 'FEDERATED' is disabled.
mysqld: Table 'mysql.plugin' doesn't exist
2022-04-22 14:18:10 1 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
2022-04-22 14:18:10 1 [Note] InnoDB: Using atomics to ref count buffer pool pages
2022-04-22 14:18:10 1 [Note] InnoDB: The InnoDB memory heap is disabled
2022-04-22 14:18:10 1 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2022-04-22 14:18:10 1 [Note] InnoDB: Memory barrier is not used
2022-04-22 14:18:10 1 [Note] InnoDB: Compressed tables use zlib 1.2.11
2022-04-22 14:18:10 1 [Note] InnoDB: Using Linux native AIO
2022-04-22 14:18:10 1 [Note] InnoDB: Using CPU crc32 instructions
2022-04-22 14:18:10 1 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2022-04-22 14:18:10 1 [Note] InnoDB: Completed initialization of buffer pool
2022-04-22 14:18:10 1 [Note] InnoDB: Highest supported file format is Barracuda.
2022-04-22 14:18:10 1 [Note] InnoDB: Log scan progressed past the checkpoint lsn 49463
2022-04-22 14:18:10 1 [Note] InnoDB: Database was not shutdown normally!
2022-04-22 14:18:10 1 [Note] InnoDB: Starting crash recovery.
2022-04-22 14:18:10 1 [Note] InnoDB: Reading tablespace information from the .ibd files...
2022-04-22 14:18:10 1 [Note] InnoDB: Restoring possible half-written data pages
2022-04-22 14:18:10 1 [Note] InnoDB: from the doublewrite buffer...
InnoDB: Doing recovery: scanned up to log sequence number 1600607
2022-04-22 14:18:10 1 [Note] InnoDB: Starting an apply batch of log records to the database...
InnoDB: Progress in percent: 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
2022-04-22 14:18:11 1 [Note] InnoDB: 128 rollback segment(s) are active.
2022-04-22 14:18:11 1 [Note] InnoDB: Waiting for purge to start
2022-04-22 14:18:11 1 [Note] InnoDB: 5.6.51 started; log sequence number 1600607
2022-04-22 14:18:11 1 [Note] RSA private key file not found: /var/lib/mysql//private_key.pem. Some authentication plugins will not work.
2022-04-22 14:18:11 1 [Note] RSA public key file not found: /var/lib/mysql//public_key.pem. Some authentication plugins will not work.
2022-04-22 14:18:11 1 [Note] Server hostname (bind-address): '*'; port: 3306
2022-04-22 14:18:11 1 [Note] IPv6 is available.
2022-04-22 14:18:11 1 [Note] - '::' resolves to '::';
2022-04-22 14:18:11 1 [Note] Server socket created on IP: '::'.
2022-04-22 14:18:11 1 [Warning] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory.
2022-04-22 14:18:11 1 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.user' doesn't exist
解決辦法
問(wèn)題原因:
經(jīng)過(guò)系統(tǒng)排查,文件對(duì)比,發(fā)現(xiàn)是因?yàn)槿鄙費(fèi)ySQL數(shù)據(jù)庫(kù)的系統(tǒng)文件 “?performance_schema ”
同事在備份的時(shí)候,只關(guān)注到數(shù)據(jù)庫(kù)文件的遷移,而缺少performance_schema
第一種解決方案:
(注意:在遷移/備份數(shù)據(jù)庫(kù)前,一定要停止MySQL服務(wù),一定要?。?!不論是源服務(wù),還是目標(biāo)服務(wù))
出現(xiàn) “?Fatal error: Can‘t open and lock privilege tables: Table ‘mysql.user‘ doesn‘t exis ”?
的文件內(nèi)容如下,處理前的目錄:
把數(shù)據(jù)庫(kù)文件 “?performance_schema ” 復(fù)制到MySQL的/data文件夾后,如下圖:
再次拉MySQL容器服務(wù),就可以成功啟動(dòng)了,如下圖:?
第二種解決方案:
(這個(gè)方案適合MySQL Server直接部署到宿主機(jī)上的)
1、清空MySQL /data 目錄下的所有文件;
2、重新初始化MySQL數(shù)據(jù)庫(kù),輸入指令,
“?mysqld --initialize --user=root --basedir=/home --datadir=/var/lib/mysql ”
3、將備份的數(shù)據(jù)庫(kù)重新考入到/data目錄下,解壓,啟動(dòng)即可,
(注意在遷移備份數(shù)據(jù)庫(kù)之前,千萬(wàn)!千萬(wàn)!千萬(wàn)要停止MySQL服務(wù),否則,后面一定會(huì)出問(wèn)題,而且出了問(wèn)題還不好排查的)
補(bǔ)充知識(shí):
performance_schema & information_schema:
information_schema 數(shù)據(jù)庫(kù)跟 performance_schema 相同,都是 MySQL 自帶的信息數(shù)據(jù)庫(kù)。其中 performance_schema 主要作用于性能分析,而 information_schema 主要作用于存儲(chǔ)MySQL數(shù)據(jù)庫(kù)的元數(shù)據(jù)(數(shù)據(jù)的數(shù)據(jù)),例如:新增的數(shù)據(jù)庫(kù)屬性、表屬性、列的數(shù)據(jù)類(lèi)型、訪問(wèn)權(quán)限等屬性數(shù)據(jù)。
performance_schema是一種用于MySQL底層監(jiān)視服務(wù)執(zhí)行情況的,關(guān)于performance_schema的一些作用如下:
- 在數(shù)據(jù)庫(kù)啟動(dòng)/運(yùn)行時(shí)實(shí)時(shí)檢查記錄MySQL Server的內(nèi)部執(zhí)行情況。performance_schema 數(shù)據(jù)庫(kù)中的表使用performance_schema存儲(chǔ)引擎。該數(shù)據(jù)庫(kù)主要用于存儲(chǔ)整個(gè)MySQL數(shù)據(jù)庫(kù)運(yùn)行過(guò)程中的性能數(shù)據(jù)采集存儲(chǔ),與information_schema不同,information_schema主要關(guān)注MySQL Server運(yùn)行過(guò)程中的元數(shù)據(jù)信息;
- ?performance_schema通過(guò)監(jiān)視MySQL Server的事件來(lái)實(shí)現(xiàn)監(jiān)視服務(wù)內(nèi)部運(yùn)行情況, “事件”就是MySQL 服務(wù)內(nèi)部活動(dòng)中所做的任何事情以及對(duì)應(yīng)的時(shí)間消耗,利用這些信息來(lái)判斷MySQL的資源消耗性能瓶頸的所在,一般來(lái)說(shuō),事件可以是函數(shù)調(diào)用、操作系統(tǒng)的等待、SQL語(yǔ)句執(zhí)行的階段或者整個(gè)SQL語(yǔ)句與SQL語(yǔ)句集合。事件的采集可以方便的提供MySQL Server中的相關(guān)存儲(chǔ)引擎對(duì)磁盤(pán)文件、表I/O、表鎖等資源的調(diào)用等信息;
- ?performance_schema中的事件只記錄在本地MySQL Server的performance_schema中,但是在performance_schema數(shù)據(jù)庫(kù)下表中數(shù)據(jù)發(fā)生變化時(shí)不會(huì)被寫(xiě)入binlog中(這個(gè)是需要注意的點(diǎn)),也不會(huì)通過(guò)復(fù)制機(jī)制被復(fù)制到其他MySQL服務(wù)中;
- ?記錄當(dāng)前表中活躍事件、歷史事件和事件摘要相關(guān)的信息。例如:提供表的某個(gè)事件的執(zhí)行次數(shù)、消耗時(shí)長(zhǎng),進(jìn)而可用于分析某個(gè)特定線程、特定對(duì)象相關(guān)聯(lián)的活動(dòng);
- performance_schema中的事件與寫(xiě)入二進(jìn)制日志中的事件(數(shù)據(jù)修改的events)、計(jì)劃事件調(diào)度程序(一種存儲(chǔ)程序)的事件不同,performance_schema中的事件記錄的是執(zhí)行某些活動(dòng)對(duì)某些資源的消耗,例如:執(zhí)行的時(shí)長(zhǎng)、執(zhí)行的次數(shù)等信息;
- ?performance_schema存儲(chǔ)引擎使用MySQL Server 源代碼中的“檢測(cè)點(diǎn)”來(lái)實(shí)現(xiàn)事件數(shù)據(jù)的收集,performance_schema實(shí)現(xiàn)機(jī)制本身的代碼沒(méi)有相關(guān)的單獨(dú)線程來(lái)檢測(cè),這與其他功能有所不同,例如:復(fù)制事件、事件計(jì)劃程序;
- ?所有收集的事件信息存儲(chǔ)在performance_schema數(shù)據(jù)庫(kù)表中。這些表可以使用SELECT語(yǔ)句查詢,也可以使用SQL語(yǔ)句更新performance_schema數(shù)據(jù)庫(kù)中表的記錄,注意:performance_schema中表的修改會(huì)立即生效,影響數(shù)據(jù)采集;
- ?performance_schema中的表的數(shù)據(jù)不會(huì)持久化存儲(chǔ)在磁盤(pán)中,而是保存在“內(nèi)存”中,一旦服務(wù)器重啟,這些數(shù)據(jù)會(huì)丟失的風(fēng)險(xiǎn),包括系統(tǒng)表在內(nèi)的整個(gè)performance_schema下所有的數(shù)據(jù);
- ?只要是受MySQL Server支持平臺(tái),都可以實(shí)現(xiàn)事件監(jiān)控,但是可能會(huì)存在事件消耗計(jì)數(shù)器統(tǒng)計(jì)類(lèi)型不一的情況;
information_schema 數(shù)據(jù)庫(kù)中經(jīng)常用到的數(shù)據(jù)表:
表名 | 描述 |
---|---|
SCHEMATA | 提供了關(guān)于數(shù)據(jù)庫(kù)的信息; |
TABLES | 提供了關(guān)于數(shù)據(jù)庫(kù)中的表的信息; |
COLUMNS | 提供了表中的列信息; |
STATISTICS | 提供了關(guān)于表索引的信息; |
USER_PRIVILEGES | 提供了關(guān)于全程權(quán)限的信息,該信息源自mysql.user授權(quán)表; |
SCHEMA_PRIVILEGES | 提供了關(guān)于方案(數(shù)據(jù)庫(kù))權(quán)限的信息。該信息來(lái)自mysql.db授權(quán)表; |
TABLE_PRIVILEGES | 提供了關(guān)于表權(quán)限的信息。該信息源自mysql.tables_priv授權(quán)表; |
COLUMN_PRIVILEGES | 提供了關(guān)于列權(quán)限的信息。該信息源自mysql.columns_priv授權(quán)表; |
TABLE_CONSTRAINTS | 描述了存在約束的表; |
KEY_COLUMN_USAGE | 描述了具有約束的鍵列; |
ROUTINES | 提供了關(guān)于存儲(chǔ)子程序(存儲(chǔ)程序和函數(shù))的信息。此時(shí),ROUTINES表不包含自定義函數(shù)(UDF); |
VIEWS | 提供了關(guān)于數(shù)據(jù)庫(kù)中的視圖的信息; |
TRIGGERS | 提供了關(guān)于觸發(fā)程序的信息; |
CHARACTER_SETS | 提供了關(guān)于可用字符集的信息; |
COLLATIONS | 提供了關(guān)于各字符集的對(duì)照信息; |
關(guān)于information_schema數(shù)據(jù)庫(kù)中字段“ TABLE_CATALOG ”:
MySQL系統(tǒng)的information_schema數(shù)據(jù)庫(kù)中,很多表都存在TABLE_CATALOG字段,MYSQL官方文檔中說(shuō),這個(gè)字段值永遠(yuǎn)是def,但沒(méi)寫(xiě)明這個(gè)字段是作用什么的。博主在網(wǎng)上搜羅了一下,很多把這個(gè)叫表的“限定符”,感覺(jué)好像是和其它關(guān)系型數(shù)據(jù)庫(kù)作區(qū)分用的(Oracle、MySQL、Microsoft SQL Server、Microsoft Access等)。如下3連圖ss222:
文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-402462.html
好了,關(guān)于?Docker容器化部署報(bào)Fatal error: Can‘t open and lock privilege tables: Table ‘mysql.user‘ doesn‘t exis的解決辦法 就寫(xiě)到這兒了,如果還有什么疑問(wèn)或遇到什么問(wèn)題歡迎掃碼提問(wèn),也可以給我留言哦,我會(huì)一一詳細(xì)的解答的。?
歇后語(yǔ):“ 共同學(xué)習(xí),共同進(jìn)步 ”,也希望大家多多關(guān)注CSND的IT社區(qū)。文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-402462.html
作? ? ? ?者: | 華 ? ?仔 |
聯(lián)系作者: | who.seek.me@java98k.vip |
來(lái)? ? ? ? 源: | CSDN (Chinese Software Developer Network) |
原? ? ? ? 文: | https://blog.csdn.net/Hello_World_QWP/article/details/124350450 |
版權(quán)聲明: | 本文為博主原創(chuàng)文章,請(qǐng)?jiān)谵D(zhuǎn)載時(shí)務(wù)必注明博文出處! |
到了這里,關(guān)于Docker容器化部署報(bào)Fatal error: Can‘t open and lock privilege tables: Table ‘mysql.user‘ doesn‘t exis的解決辦法的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!