gpt4 book ai didi

mysql - 如何在不登录mysql的情况下恢复默认的[mysql]系统数据库?

转载 作者:行者123 更新时间:2023-11-29 15:25:55 25 4
gpt4 key购买 nike

好的,所以我很渴望空间,但是却愚蠢地忽略了在Ubuntu 16 VPS上删除我的mysql系统数据库。 sql服务器崩溃后,我重新启动了systemctl mysql start并获取并检查journalctl -xe错误,告诉我:

nopnotme systemd[1]: Failed to start MySQL Community Server.
-- Subject: Unit mysql.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit mysql.service has failed.
--
-- The result is failed.
Nov 28 20:19:43 nopnotme systemd[1]: mysql.service: Unit entered failed state.
Nov 28 20:19:43 nopnotme systemd[1]: mysql.service: Failed with result 'exit-code'.



然后我检查了/var/log/mysql/error.log:

2019-11-28T19:40:30.996439Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2019-11-28T19:40:30.996491Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2019-11-28T19:40:31.130146Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2019-11-28T19:40:31.134049Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
2019-11-28T19:40:31.134066Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
2019-11-28T19:40:31.138841Z 0 [Note] InnoDB: Waiting for purge to start
2019-11-28T19:40:31.189158Z 0 [Note] InnoDB: 5.7.28 started; log sequence number 3940166
2019-11-28T19:40:31.197376Z 0 [Note] Plugin 'FEDERATED' is disabled.
mysqld: Table 'mysql.plugin' doesn't exist
2019-11-28T19:40:31.201952Z 0 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
2019-11-28T19:40:31.202171Z 0 [ERROR] unknown option '--install'
2019-11-28T19:40:31.202181Z 0 [ERROR] Aborting

2019-11-28T19:40:31.202192Z 0 [Note] Binlog end
2019-11-28T19:40:31.202237Z 0 [Note] Shutting down plugin 'ngram'


ect ..(更多插件)

2019-11-28T19:40:31.202439Z 0 [Note] Shutting down plugin 'InnoDB'
2019-11-28T19:40:31.202487Z 0 [Note] InnoDB: FTS optimize thread exiting.
2019-11-28T19:40:31.202602Z 0 [Note] InnoDB: Starting shutdown...
2019-11-28T19:40:31.202670Z 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
2019-11-28T19:40:31.230348Z 0 [Note] InnoDB: Buffer pool(s) load completed at 191128 19:40:31 (/var/lib/mysql/ib_buffer_pool was empty)


所以我假设我没有遇到内存错误:

2019-11-28T19:40:31.230375Z 0 [Note] InnoDB: Dumping buffer pool(s) to /var/lib/mysql/ib_buffer_pool
2019-11-28T19:40:31.272173Z 0 [Note] InnoDB: Buffer pool(s) dump completed at 191128 19:40:31
2019-11-28T19:40:33.019782Z 0 [Note] InnoDB: Shutdown completed; log sequence number 3942367
2019-11-28T19:40:33.022780Z 0 [Note] InnoDB: Removed temporary tablespace data file: "ibtmp1"
2019-11-28T19:40:33.022793Z 0 [Note] Shutting down plugin 'MEMORY'
2019-11-28T19:40:33.022802Z 0 [Note] Shutting down plugin 'MyISAM'
2019-11-28T19:40:33.022812Z 0 [Note] Shutting down plugin 'sha256_password'
2019-11-28T19:40:33.022816Z 0 [Note] Shutting down plugin 'mysql_native_password'
2019-11-28T19:40:33.022943Z 0 [Note] Shutting down plugin 'binlog'
2019-11-28T19:40:33.023350Z 0 [Note] mysqld: Shutdown complete


我认为问题的根源在于我删除了系统文件,现在我无法登录以运行 mysql_upgrade

有什么想法吗?

编辑1
另请注意,/ var / lib / mysql目录的权限为 mysql:mysql

编辑2
我已经看到了这个问题: How to recover/recreate mysql's default 'mysql' database。但是,我无法登录并出现 Got error: 2002: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) when trying to connect错误。

最佳答案

解决了问题(解决方法)
位于/var/lib/mysql/{DATABASE}的已保存数据库文件* .frm和* .idb文件。
然后,我使用this方法卸载了sql-server。
重新安装并确认mysql正在运行并具有[information_schema]和[mysql]默认数据库后;我跟随this使用mysqlfrm --diagnostic {.frm file}重新生成表结构,以生成sql查询。
然后取消链接空的DATASPACE,以允许我导入我的真实DATASPACE(* .idb)。在将数据文件移回目录chown -R "mysql:mysql" /var/lib/mysql/时,请确保更新文件许可权。
备份并运行!

关于mysql - 如何在不登录mysql的情况下恢复默认的[mysql]系统数据库?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59095893/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com