暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

ubuntu服务器mysql异常断电,异机恢复过程

原创 伟鹏 2023-10-09
1341
  • 1、将异常断电服务器的mysql所在data目录传输到新服务器上
    2、删除系统之前的数据库(操作前做好备份)
    root@ts-OMEN-by-HP-Gaming-Laptop-16-k0xxx:/home/ts/Downloads/mysql# apt-get autoremove --purge mysql-server -y && apt-get remove mysql-common -y && rm -rf /etc/mysql/ /var/lib/mysql
    Reading package lists... Done
    Building dependency tree... Done
    Reading state information... Done
    The following packages will be REMOVED:
    gdal-data* gir1.2-gst-plugins-bad-1.0* ibverbs-providers* libaec0* libarmadillo10* libarpack2* libavcodec-dev* libavformat-dev* libavutil-dev* libblosc1* libcfitsio9* libcharls2* libdc1394-dev* libdeflate-dev* libevent-core-2.1-7*
    libevent-pthreads-2.1-7* libexif-dev* libexif-doc* libfabric1* libfreexl1* libfyba0* libgdcm-dev* libgdcm3.0* libgeos-c1v5* libgeos3.10.2* libgeotiff5* libgl2ps1.4* libglew2.2* libgphoto2-dev* libgstreamer-opencv1.0-0* libhdf4-0-alt*
    libhdf5-103-1* libhdf5-hl-100* libhtml-template-perl* libhwloc-plugins* libhwloc15* libibverbs1* libilmbase-dev* libjbig-dev* libjpeg-dev* libjpeg-turbo8-dev* libjpeg8-dev* libkmlbase1* libkmldom1* libkmlengine1* liblept5* libmecab2*
    libnetcdf19* libodbcinst2* libogdi4.1* libopencv-calib3d4.5d* libopencv-core-dev* libopencv-core4.5d* libopencv-dnn-dev* libopencv-dnn4.5d* libopencv-features2d4.5d* libopencv-flann-dev* libopencv-flann4.5d* libopencv-imgproc-dev*
    libopencv-imgproc4.5d* libopencv-ml-dev* libopencv-ml4.5d* libopencv-objdetect4.5d* libopencv-photo-dev* libopencv-photo4.5d* libopencv-shape-dev* libopencv-shape4.5d* libopencv-stitching4.5d* libopencv-video-dev* libopencv-video4.5d*
    libopencv-viz-dev* libopencv-viz4.5d* libopenexr-dev* libopenmpi3* libpmix2* libpng-dev* libpng-tools* libpq5* libproj22* libpsm-infinipath1* libpsm2-2* libqhull-r8.0* libraw1394-dev* libraw1394-tools* librdmacm1* librttopo1*
    libsocket++1* libspatialite7* libsuperlu5* libswresample-dev* libswscale-dev* libsz2* libtbb-dev* libtbb12* libtbb2* libtbbmalloc2* libtesseract4* libtiff-dev* libtiffxx5* libucx0* liburiparser1* libvtk9.1* libxerces-c3.2* mecab-ipadic*
    mecab-ipadic-utf8* mecab-utils* mysql-server* mysql-server-8.0* mysql-server-core-8.0* opencv-data* proj-bin* proj-data* unixodbc-common*
    0 upgraded, 0 newly installed, 113 to remove and 0 not upgraded.
    After this operation, 507 MB disk space will be freed.
    (Reading database ... 361148 files and directories currently installed.)
    Removing gdal-data (3.4.1+dfsg-1build4) ...
    Removing gir1.2-gst-plugins-bad-1.0:amd64 (1.20.3-0ubuntu1) ...
    Removing libopencv-viz-dev:amd64 (4.5.4+dfsg-9ubuntu4) ...
    Removing libopencv-viz4.5d:amd64 (4.5.4+dfsg-9ubuntu4) ...
    Removing libvtk9.1:amd64 (9.1.0+really9.1.0+dfsg2-3build1) ...
    Removing libopenmpi3:amd64 (4.1.2-2ubuntu1) ...
    Removing libucx0:amd64 (1.12.1~rc2-1) ...
    Removing libfabric1:amd64 (1.11.0-3) ...
    Removing ibverbs-providers:amd64 (39.0-1) ...
    Removing libnetcdf19:amd64 (1:4.8.1-1) ...
    Removing libhdf5-hl-100:amd64 (1.10.7+repack-4ubuntu2) ...
    Removing libhdf5-103-1:amd64 (1.10.7+repack-4ubuntu2) ...
    Removing libsz2:amd64 (1.0.6-1) ...
    Removing libaec0:amd64 (1.0.6-1) ...
    Removing libarmadillo10 (1:10.8.2+dfsg-1) ...
    Removing libarpack2:amd64 (3.8.0-1) ...
    Removing libavformat-dev:amd64 (7:4.4.2-0ubuntu0.22.04.1) ...
    Removing libavcodec-dev:amd64 (7:4.4.2-0ubuntu0.22.04.1) ...
    Removing libswscale-dev:amd64 (7:4.4.2-0ubuntu0.22.04.1) ...
    Removing libswresample-dev:amd64 (7:4.4.2-0ubuntu0.22.04.1) ...
    Removing libavutil-dev:amd64 (7:4.4.2-0ubuntu0.22.04.1) ...
    Removing libblosc1:amd64 (1.21.1+ds2-2) ...
    Removing libcfitsio9:amd64 (4.0.0-1) ...
    Removing libgdcm-dev (3.0.10-1build2) ...
    Removing libgdcm3.0:amd64 (3.0.10-1build2) ...
    Removing libcharls2:amd64 (2.3.4-1) ...
    Removing libdc1394-dev:amd64 (2.2.6-4) ...
    Removing libtiff-dev:amd64 (4.3.0-6ubuntu0.5) ...
    Removing libdeflate-dev:amd64 (1.10-2) ...
    Removing mysql-server (8.0.34-0ubuntu0.22.04.1) ...
    Removing mysql-server-8.0 (8.0.34-0ubuntu0.22.04.1) ...
    Removing mysql-server-core-8.0 (8.0.34-0ubuntu0.22.04.1) ...
    Removing libpmix2:amd64 (4.1.2-2ubuntu1) ...
    Removing libevent-pthreads-2.1-7:amd64 (2.1.12-stable-1build3) ...
    Removing libgphoto2-dev:amd64 (2.5.27-1build2) ...
    Removing libexif-dev:amd64 (0.6.24-1build1) ...
    Removing libexif-doc (0.6.24-1build1) ...
    Removing libspatialite7:amd64 (5.0.1-2build2) ...
    Removing libfreexl1:amd64 (1.0.6-1) ...
    Removing libfyba0:amd64 (4.1.1-7) ...
    Removing librttopo1:amd64 (1.1.0-2) ...
    Removing libgeos-c1v5:amd64 (3.10.2-1) ...
    Removing libgeos3.10.2:amd64 (3.10.2-1) ...
    Removing libgeotiff5:amd64 (1.7.0-2build1) ...
    Removing libgl2ps1.4 (1.4.2+dfsg1-2) ...
    Removing libglew2.2:amd64 (2.2.0-4) ...
    Removing libgstreamer-opencv1.0-0:amd64 (1.20.3-0ubuntu1) ...
    Removing libhdf4-0-alt (4.2.15-4) ...
    Removing libhtml-template-perl (2.97-1.1) ...
    Removing libhwloc-plugins:amd64 (2.7.0-2ubuntu1) ...
    Removing libhwloc15:amd64 (2.7.0-2ubuntu1) ...
    Removing librdmacm1:amd64 (39.0-1) ...
    Removing libibverbs1:amd64 (39.0-1) ...
    Removing libopenexr-dev (2.5.7-1) ...
    Removing libilmbase-dev:amd64 (2.5.7-2) ...
    Removing libjbig-dev:amd64 (2.1-3.1ubuntu0.22.04.1) ...
    Removing libjpeg-dev:amd64 (8c-2ubuntu10) ...
    Removing libjpeg8-dev:amd64 (8c-2ubuntu10) ...
    Removing libjpeg-turbo8-dev:amd64 (2.1.2-0ubuntu1) ...
    Removing libkmlengine1:amd64 (1.3.0-9) ...
    Removing libkmldom1:amd64 (1.3.0-9) ...
    Removing libkmlbase1:amd64 (1.3.0-9) ...
    Removing libtesseract4:amd64 (4.1.1-2.1build1) ...
    Removing liblept5:amd64 (1.82.0-3build1) ...
    Removing mecab-ipadic-utf8 (2.7.0-20070801+main-3) ...
    update-alternatives: using /var/lib/mecab/dic/ipadic to provide /var/lib/mecab/dic/debian (mecab-dictionary) in auto mode
    Removing mecab-ipadic (2.7.0-20070801+main-3) ...
    Removing mecab-utils (0.996-14build9) ...
    Removing libmecab2:amd64 (0.996-14build9) ...
    Removing libodbcinst2:amd64 (2.3.9-5) ...
    Removing libogdi4.1 (4.1.0+ds-5) ...
    Removing libopencv-shape-dev:amd64 (4.5.4+dfsg-9ubuntu4) ...
    Removing libopencv-video-dev:amd64 (4.5.4+dfsg-9ubuntu4) ...
    Removing libopencv-video4.5d:amd64 (4.5.4+dfsg-9ubuntu4) ...
    Removing libopencv-stitching4.5d:amd64 (4.5.4+dfsg-9ubuntu4) ...
    Removing libopencv-ml-dev:amd64 (4.5.4+dfsg-9ubuntu4) ...
    Removing libopencv-photo-dev:amd64 (4.5.4+dfsg-9ubuntu4) ...
    Removing libopencv-imgproc-dev:amd64 (4.5.4+dfsg-9ubuntu4) ...
    Removing libopencv-shape4.5d:amd64 (4.5.4+dfsg-9ubuntu4) ...
    Removing libopencv-dnn-dev:amd64 (4.5.4+dfsg-9ubuntu4) ...
    Removing libopencv-objdetect4.5d:amd64 (4.5.4+dfsg-9ubuntu4) ...
    Removing libopencv-dnn4.5d:amd64 (4.5.4+dfsg-9ubuntu4) ...
    Removing libopencv-flann-dev:amd64 (4.5.4+dfsg-9ubuntu4) ...
    Removing libopencv-photo4.5d:amd64 (4.5.4+dfsg-9ubuntu4) ...
    Removing libopencv-ml4.5d:amd64 (4.5.4+dfsg-9ubuntu4) ...
    Removing libpng-dev:amd64 (1.6.37-3build5) ...
    Removing libpng-tools (1.6.37-3build5) ...
    Removing libpq5:amd64 (14.9-0ubuntu0.22.04.1) ...
    Removing proj-bin (8.2.1-1) ...
    Removing libproj22:amd64 (8.2.1-1) ...
    Removing libpsm-infinipath1 (3.3+20.604758e7-6.1) ...
    update-alternatives: warning: alternative /usr/lib/libpsm1/libpsm_infinipath.so.1.16 (part of link group libpsm_infinipath.so.1) doesn't exist; removing from list of alternatives
    update-alternatives: warning: /etc/alternatives/libpsm_infinipath.so.1 is dangling; it will be updated with best choice
    Removing libpsm2-2 (11.2.185-1) ...
    Removing libqhull-r8.0:amd64 (2020.2-4) ...
    Removing libraw1394-dev:amd64 (2.1.2-2build2) ...
    Removing libraw1394-tools (2.1.2-2build2) ...
    Removing libsocket++1:amd64 (1.12.13+git20131030.5d039ba-1) ...
    Removing libsuperlu5:amd64 (5.3.0+dfsg1-2) ...
    Removing libtiffxx5:amd64 (4.3.0-6ubuntu0.5) ...
    Removing liburiparser1:amd64 (0.9.6+dfsg-1) ...
    Removing libxerces-c3.2:amd64 (3.2.3+debian-3build1) ...
    Removing opencv-data (4.5.4+dfsg-9ubuntu4) ...
    Removing proj-data (8.2.1-1) ...
    Removing unixodbc-common (2.3.9-5) ...
    Removing libevent-core-2.1-7:amd64 (2.1.12-stable-1build3) ...
    Removing libopencv-calib3d4.5d:amd64 (4.5.4+dfsg-9ubuntu4) ...
    Removing libopencv-core-dev:amd64 (4.5.4+dfsg-9ubuntu4) ...
    Removing libopencv-features2d4.5d:amd64 (4.5.4+dfsg-9ubuntu4) ...
    Removing libopencv-flann4.5d:amd64 (4.5.4+dfsg-9ubuntu4) ...
    Removing libopencv-imgproc4.5d:amd64 (4.5.4+dfsg-9ubuntu4) ...
    Removing libtbb-dev:amd64 (2021.5.0-7ubuntu2) ...
    Removing libtbb12:amd64 (2021.5.0-7ubuntu2) ...
    Removing libopencv-core4.5d:amd64 (4.5.4+dfsg-9ubuntu4) ...
    Removing libtbb2:amd64 (2020.3-1ubuntu3) ...
    Removing libtbbmalloc2:amd64 (2021.5.0-7ubuntu2) ...
    Processing triggers for man-db (2.10.2-1) ...
    Processing triggers for libc-bin (2.35-0ubuntu3.4) ...
    (Reading database ... 358064 files and directories currently installed.)
    Purging configuration files for mysql-server-8.0 (8.0.34-0ubuntu0.22.04.1) ...
    Purging configuration files for libmecab2:amd64 (0.996-14build9) ...
    Purging configuration files for ibverbs-providers:amd64 (39.0-1) ...
    Purging configuration files for libopenexr-dev (2.5.7-1) ...
    Purging configuration files for unixodbc-common (2.3.9-5) ...
    Purging configuration files for libpsm-infinipath1 (3.3+20.604758e7-6.1) ...
    Reading package lists... Done
    Building dependency tree... Done
    Reading state information... Done
    The following package was automatically installed and is no longer required:
    mysql-client-core-8.0
    Use 'apt autoremove' to remove it.
    The following packages will be REMOVED:
    mysql-client mysql-client-8.0 mysql-common
    0 upgraded, 0 newly installed, 3 to remove and 0 not upgraded.
    After this operation, 164 kB disk space will be freed.
    (Reading database ... 358033 files and directories currently installed.)
    Removing mysql-client (8.0.34-0ubuntu0.22.04.1) ...
    Removing mysql-client-8.0 (8.0.34-0ubuntu0.22.04.1) ...
    Removing mysql-common (5.8+1.0.8) ...
    Processing triggers for man-db (2.10.2-1) ...

    3、解压下载的tar文件
    root@ts-OMEN-by-HP-Gaming-Laptop-16-k0xxx:/home/ts/Downloads/mysql# tar -xvf mysql-server_8.1.0-1ubuntu22.04_amd64.deb-bundle.tar
    libmysqlclient22_8.1.0-1ubuntu22.04_amd64.deb
    libmysqlclient-dev_8.1.0-1ubuntu22.04_amd64.deb
    mysql-client_8.1.0-1ubuntu22.04_amd64.deb
    mysql-common_8.1.0-1ubuntu22.04_amd64.deb
    mysql-community-client_8.1.0-1ubuntu22.04_amd64.deb
    mysql-community-client-core_8.1.0-1ubuntu22.04_amd64.deb
    mysql-community-client-plugins_8.1.0-1ubuntu22.04_amd64.deb
    mysql-community-server_8.1.0-1ubuntu22.04_amd64.deb
    mysql-community-server-core_8.1.0-1ubuntu22.04_amd64.deb
    mysql-community-server-debug_8.1.0-1ubuntu22.04_amd64.deb
    mysql-community-test_8.1.0-1ubuntu22.04_amd64.deb
    mysql-community-test-debug_8.1.0-1ubuntu22.04_amd64.deb
    mysql-server_8.1.0-1ubuntu22.04_amd64.deb
    mysql-testsuite_8.1.0-1ubuntu22.04_amd64.deb

    4、安装mysql的deb包
    root@ts-OMEN-by-HP-Gaming-Laptop-16-k0xxx:/home/ts/Downloads/mysql# dpkg -i mysql-community-client_8.1.0-1ubuntu22.04_amd64.deb
    Selecting previously unselected package mysql-community-client.
    dpkg: considering removing mysql-client-core-8.0 in favour of mysql-community-client ...
    dpkg: yes, will remove mysql-client-core-8.0 in favour of mysql-community-client
    (Reading database ... 358009 files and directories currently installed.)
    Preparing to unpack mysql-community-client_8.1.0-1ubuntu22.04_amd64.deb ...
    Unpacking mysql-community-client (8.1.0-1ubuntu22.04) ...
    Removing mysql-client-core-8.0 (8.0.34-0ubuntu0.22.04.1), to allow configuration of mysql-community-client (8.1.0-1ubuntu22.04) ...
    dpkg: dependency problems prevent configuration of mysql-community-client:
    mysql-community-client depends on mysql-common (>= 8.1.0-1ubuntu22.04); however:
    Package mysql-common is not installed.
    mysql-community-client depends on mysql-community-client-core (= 8.1.0-1ubuntu22.04); however:
    Package mysql-community-client-core is not installed.

    dpkg: error processing package mysql-community-client (--install):
    dependency problems - leaving unconfigured
    Processing triggers for man-db (2.10.2-1) ...
    Errors were encountered while processing:
    mysql-community-client
    4.1提示有依赖deb包需要安装
    root@ts-OMEN-by-HP-Gaming-Laptop-16-k0xxx:/home/ts/Downloads/mysql# dpkg -i mysql-common_8.1.0-1ubuntu22.04_amd64.deb
    Selecting previously unselected package mysql-common.
    (Reading database ... 358034 files and directories currently installed.)
    Preparing to unpack mysql-common_8.1.0-1ubuntu22.04_amd64.deb ...
    Unpacking mysql-common (8.1.0-1ubuntu22.04) ...
    Setting up mysql-common (8.1.0-1ubuntu22.04) ...

    Configuration file '/etc/mysql/conf.d/mysql.cnf'
    ==> Deleted (by you or by a script) since installation.
    ==> Package distributor has shipped an updated version.
    What would you like to do about it ? Your options are:
    Y or I : install the package maintainer's version
    N or O : keep your currently-installed version
    D : show the differences between the versions
    Z : start a shell to examine the situation
    The default action is to keep your current version.
    *** mysql.cnf (Y/I/N/O/D/Z) [default=N] ? y
    Installing new version of config file /etc/mysql/conf.d/mysql.cnf ...

    Configuration file '/etc/mysql/my.cnf.fallback'
    ==> Deleted (by you or by a script) since installation.
    ==> Package distributor has shipped an updated version.
    What would you like to do about it ? Your options are:
    Y or I : install the package maintainer's version
    N or O : keep your currently-installed version
    D : show the differences between the versions
    Z : start a shell to examine the situation
    The default action is to keep your current version.
    *** my.cnf.fallback (Y/I/N/O/D/Z) [default=N] ? y
    Installing new version of config file /etc/mysql/my.cnf.fallback ...
    update-alternatives: using /etc/mysql/my.cnf.fallback to provide /etc/mysql/my.cnf (my.cnf) in auto mode
    root@ts-OMEN-by-HP-Gaming-Laptop-16-k0xxx:/home/ts/Downloads/mysql# vi /etc/mysql/my.cnf
    root@ts-OMEN-by-HP-Gaming-Laptop-16-k0xxx:/home/ts/Downloads/mysql# dpkg -i mysql-common_8.1.0-1ubuntu22.04_amd64.deb
    (Reading database ... 358039 files and directories currently installed.)
    Preparing to unpack mysql-common_8.1.0-1ubuntu22.04_amd64.deb ...
    Unpacking mysql-common (8.1.0-1ubuntu22.04) over (8.1.0-1ubuntu22.04) ...
    Setting up mysql-common (8.1.0-1ubuntu22.04) ...

    4.2 根据提示安装需要的ded包
    root@ts-OMEN-by-HP-Gaming-Laptop-16-k0xxx:/home/ts/Downloads/mysql# dpkg -i mysql-client_8.1.0-1ubuntu22.04_amd64.deb
    Selecting previously unselected package mysql-client.
    (Reading database ... 358039 files and directories currently installed.)
    Preparing to unpack mysql-client_8.1.0-1ubuntu22.04_amd64.deb ...
    Unpacking mysql-client (8.1.0-1ubuntu22.04) ...
    dpkg: dependency problems prevent configuration of mysql-client:
    mysql-client depends on mysql-community-client (= 8.1.0-1ubuntu22.04); however:
    Package mysql-community-client is not configured yet.

    dpkg: error processing package mysql-client (--install):
    dependency problems - leaving unconfigured
    Errors were encountered while processing:
    mysql-client
    4.3 依旧提示友依赖包,根据提示安装
    root@ts-OMEN-by-HP-Gaming-Laptop-16-k0xxx:/home/ts/Downloads/mysql# dpkg -i mysql-community-server-core_8.1.0-1ubuntu22.04_amd64.deb
    Selecting previously unselected package mysql-community-server-core.
    (Reading database ... 358045 files and directories currently installed.)
    Preparing to unpack mysql-community-server-core_8.1.0-1ubuntu22.04_amd64.deb ...
    Unpacking mysql-community-server-core (8.1.0-1ubuntu22.04) ...
    dpkg: dependency problems prevent configuration of mysql-community-server-core:
    mysql-community-server-core depends on libmecab2 (>= 0.996); however:
    Package libmecab2 is not installed.

    dpkg: error processing package mysql-community-server-core (--install):
    dependency problems - leaving unconfigured
    Processing triggers for libc-bin (2.35-0ubuntu3.4) ...
    Processing triggers for man-db (2.10.2-1) ...
    Errors were encountered while processing:
    mysql-community-server-core
    4.4 安装依赖包libmecab2
    root@ts-OMEN-by-HP-Gaming-Laptop-16-k0xxx:/home/ts/Downloads/mysql# apt-get install libmecab2
    Reading package lists... Done
    Building dependency tree... Done
    Reading state information... Done
    You might want to run 'apt --fix-broken install' to correct these.
    The following packages have unmet dependencies:
    mysql-community-client : Depends: mysql-community-client-core (= 8.1.0-1ubuntu22.04) but it is not installable
    E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).
    root@ts-OMEN-by-HP-Gaming-Laptop-16-k0xxx:/home/ts/Downloads/mysql# apt --fix-broken install
    Reading package lists... Done
    Building dependency tree... Done
    Reading state information... Done
    Correcting dependencies... Done
    The following additional packages will be installed:
    libmecab2
    The following packages will be REMOVED:
    mysql-client mysql-community-client
    The following NEW packages will be installed:
    libmecab2
    0 upgraded, 1 newly installed, 2 to remove and 0 not upgraded.
    3 not fully installed or removed.
    Need to get 0 B/199 kB of archives.
    After this operation, 42.9 MB disk space will be freed.
    Do you want to continue? [Y/n] y
    (Reading database ... 358221 files and directories currently installed.)
    Removing mysql-client (8.1.0-1ubuntu22.04) ...
    Removing mysql-community-client (8.1.0-1ubuntu22.04) ...
    Selecting previously unselected package libmecab2:amd64.
    (Reading database ... 358192 files and directories currently installed.)
    Preparing to unpack .../libmecab2_0.996-14build9_amd64.deb ...
    Unpacking libmecab2:amd64 (0.996-14build9) ...
    Setting up libmecab2:amd64 (0.996-14build9) ...
    Setting up mysql-community-server-core (8.1.0-1ubuntu22.04) ...
    Processing triggers for man-db (2.10.2-1) ...
    Processing triggers for libc-bin (2.35-0ubuntu3.4) ...
    4.5 继续安装mysql-community-server-core包
    root@ts-OMEN-by-HP-Gaming-Laptop-16-k0xxx:/home/ts/Downloads/mysql# dpkg -i mysql-community-server-core_8.1.0-1ubuntu22.04_amd64.deb
    (Reading database ... 358198 files and directories currently installed.)
    Preparing to unpack mysql-community-server-core_8.1.0-1ubuntu22.04_amd64.deb ...
    Unpacking mysql-community-server-core (8.1.0-1ubuntu22.04) over (8.1.0-1ubuntu22.04) ...
    Setting up mysql-community-server-core (8.1.0-1ubuntu22.04) ...
    Processing triggers for libc-bin (2.35-0ubuntu3.4) ...
    Processing triggers for man-db (2.10.2-1) ...
    root@ts-OMEN-by-HP-Gaming-Laptop-16-k0xxx:/home/ts/Downloads/mysql# dpkg -i mysql-client_8.1.0-1ubuntu22.04_amd64.deb
    (Reading database ... 358275 files and directories currently installed.)
    Preparing to unpack mysql-client_8.1.0-1ubuntu22.04_amd64.deb ...
    Unpacking mysql-client (8.1.0-1ubuntu22.04) over (8.1.0-1ubuntu22.04) ...
    Setting up mysql-client (8.1.0-1ubuntu22.04) ...
    root@ts-OMEN-by-HP-Gaming-Laptop-16-k0xxx:/home/ts/Downloads/mysql# dpkg -i mysql-community-server_8.1.0-1ubuntu22.04_amd64.deb
    (Reading database ... 358275 files and directories currently installed.)
    Preparing to unpack mysql-community-server_8.1.0-1ubuntu22.04_amd64.deb ...
    Unpacking mysql-community-server (8.1.0-1ubuntu22.04) over (8.1.0-1ubuntu22.04) ...
    Setting up mysql-community-server (8.1.0-1ubuntu22.04) ...
    update-alternatives: using /etc/mysql/mysql.cnf to provide /etc/mysql/my.cnf (my.cnf) in auto mode
    my_print_defaults: [Warning] World-writable config file '/etc/my.cnf' is ignored.
    my_print_defaults: [Warning] World-writable config file '/etc/my.cnf' is ignored.
    my_print_defaults: [Warning] World-writable config file '/etc/my.cnf' is ignored.
    my_print_defaults: [Warning] World-writable config file '/etc/my.cnf' is ignored.
    mysqld: [Warning] World-writable config file '/etc/my.cnf' is ignored.
    Created symlink /etc/systemd/system/multi-user.target.wants/mysql.service → /lib/systemd/system/mysql.service.
    root@ts-OMEN-by-HP-Gaming-Laptop-16-k0xxx:/home/ts/Downloads/mysql#
    root@ts-OMEN-by-HP-Gaming-Laptop-16-k0xxx:/home/ts/Downloads/mysql#
    root@ts-OMEN-by-HP-Gaming-Laptop-16-k0xxx:/home/ts/Downloads/mysql#
    root@ts-OMEN-by-HP-Gaming-Laptop-16-k0xxx:/home/ts/Downloads/mysql#
    root@ts-OMEN-by-HP-Gaming-Laptop-16-k0xxx:/home/ts/Downloads/mysql#
    root@ts-OMEN-by-HP-Gaming-Laptop-16-k0xxx:/home/ts/Downloads/mysql# cat /etc/mysql/mysql.cnf
    # Copyright (c) 2015, 2023, Oracle and/or its affiliates.
    #
    # This program is free software; you can redistribute it and/or modify
    # it under the terms of the GNU General Public License, version 2.0,
    # as published by the Free Software Foundation.
    #
    # This program is also distributed with certain software (including
    # but not limited to OpenSSL) that is licensed under separate terms,
    # as designated in a particular file or component or in included license
    # documentation. The authors of MySQL hereby grant you an additional
    # permission to link the program and your derivative works with the
    # separately licensed software that they have included with MySQL.
    #
    # This program is distributed in the hope that it will be useful,
    # but WITHOUT ANY WARRANTY; without even the implied warranty of
    # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    # GNU General Public License, version 2.0, for more details.
    #
    # You should have received a copy of the GNU General Public License
    # along with this program; if not, write to the Free Software
    # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

    #
    # The MySQL Server configuration file.
    #
    # For explanations see
    # http://dev.mysql.com/doc/mysql/en/server-system-variables.html

    # * IMPORTANT: Additional settings that can override those from this file!
    # The files must end with '.cnf', otherwise they'll be ignored.
    #
    !includedir /etc/mysql/conf.d/
    !includedir /etc/mysql/mysql.conf.d/
    root@ts-OMEN-by-HP-Gaming-Laptop-16-k0xxx:/home/ts/Downloads/mysql#
    root@ts-OMEN-by-HP-Gaming-Laptop-16-k0xxx:/home/ts/Downloads/mysql#
    root@ts-OMEN-by-HP-Gaming-Laptop-16-k0xxx:/home/ts/Downloads/mysql#
    root@ts-OMEN-by-HP-Gaming-Laptop-16-k0xxx:/home/ts/Downloads/mysql#
    root@ts-OMEN-by-HP-Gaming-Laptop-16-k0xxx:/home/ts/Downloads/mysql# vi /etc/mysql/mysql.conf.d/mysqld.cnf
    root@ts-OMEN-by-HP-Gaming-Laptop-16-k0xxx:/home/ts/Downloads/mysql# service mysql status
    ● mysql.service - MySQL Community Server
    Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
    Active: active (running) since Sun 2023-10-08 14:30:19 CST; 1min 41s ago
    Docs: man:mysqld(8)
    http://dev.mysql.com/doc/refman/en/using-systemd.html
    Main PID: 1963037 (mysqld)
    Status: "Server is operational"
    Tasks: 37 (limit: 18687)
    Memory: 364.8M
    CPU: 1.130s
    CGroup: /system.slice/mysql.service
    └─1963037 /usr/sbin/mysqld

    10月 08 14:30:18 ts-OMEN-by-HP-Gaming-Laptop-16-k0xxx systemd[1]: Starting MySQL Community Server...
    10月 08 14:30:18 ts-OMEN-by-HP-Gaming-Laptop-16-k0xxx mysql-systemd-start[1963001]: my_print_defaults: [Warning] World-writable config file '/etc/my.cnf' is ignored.
    10月 08 14:30:18 ts-OMEN-by-HP-Gaming-Laptop-16-k0xxx mysql-systemd-start[1963006]: my_print_defaults: [Warning] World-writable config file '/etc/my.cnf' is ignored.
    10月 08 14:30:18 ts-OMEN-by-HP-Gaming-Laptop-16-k0xxx mysql-systemd-start[1963012]: my_print_defaults: [Warning] World-writable config file '/etc/my.cnf' is ignored.
    10月 08 14:30:18 ts-OMEN-by-HP-Gaming-Laptop-16-k0xxx mysql-systemd-start[1963018]: my_print_defaults: [Warning] World-writable config file '/etc/my.cnf' is ignored.
    10月 08 14:30:18 ts-OMEN-by-HP-Gaming-Laptop-16-k0xxx mysql-systemd-start[1963025]: my_print_defaults: [Warning] World-writable config file '/etc/my.cnf' is ignored.
    10月 08 14:30:18 ts-OMEN-by-HP-Gaming-Laptop-16-k0xxx mysql-systemd-start[1963030]: my_print_defaults: [Warning] World-writable config file '/etc/my.cnf' is ignored.
    10月 08 14:30:18 ts-OMEN-by-HP-Gaming-Laptop-16-k0xxx mysqld[1963037]: mysqld: [Warning] World-writable config file '/etc/my.cnf' is ignored.
    10月 08 14:30:19 ts-OMEN-by-HP-Gaming-Laptop-16-k0xxx systemd[1]: Started MySQL Community Server.

    4.6 安装成功。。。
    5 恢复数据库
    关闭数据库,并将另外一台机器异常宕机的data文件copy到datadir目录,启动数据库:
    service mysql start
    6 、查看数据库的一个表报错:
    mysql> show databases;
    +--------------------+
    | Database |
    +--------------------+
    | information_schema |
    | moxingbao |
    | mysql |
    | nacos |
    | performance_schema |
    | sys |
    +--------------------+
    6 rows in set (0.01 sec)

    mysql> use moxingbao
    No connection. Trying to reconnect...
    Connection id: 9
    Current database: *** NONE ***

    Reading table information for completion of table and column names
    You can turn off this feature to get a quicker startup with -A

    Database changed
    mysql> select * from sys_user;
    ERROR 2013 (HY000): Lost connection to MySQL server during query
    mysql> desc sys_user;
    ERROR 2013 (HY000): Lost connection to MySQL server during query
    No connection. Trying to reconnect...
    Connection id: 8
    Current database: moxingbao

    7、但是用limit限制就能查出来

    mysql> select * from sys_user limit 1;
    +---------------------+------------------------------+----------------+------------------------------------------------------------------+----------+--------+----------+------+------------------------------+-------------+----------+--------+---------------+---------+------+-----------+---------------+------------+----------------+-----------+----------+------------+-----------+--------------------------------------------------------------------------+-----------+---------------------+------------------------------+---------------------+
    | id | username | realname | password | salt | avatar | birthday | sex | email | phone | org_code | status | activiti_sync | work_no | post | telephone | user_identity | depart_ids | rel_tenant_ids | client_id | due_date | first_name | last_name | head_url | create_by | create_time | update_by | update_time |
    +---------------------+------------------------------+----------------+------------------------------------------------------------------+----------+--------+----------+------+------------------------------+-------------+----------+--------+---------------+---------+------+-----------+---------------+------------+----------------+-----------+----------+------------+-----------+--------------------------------------------------------------------------+-----------+---------------------+------------------------------+---------------------+
    | 1435803983661027330 | modelfarm.ai@thundercomm.com | ModelFarm Demo | a728e4821c289c6b12420971336612dda4a471b8a63ef5531501227205824ad5 | gJU1T2sY | NULL | NULL | NULL | modelfarm.ai@thundercomm.com | 01062662686 | A03 | 1 | 0 | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | susie | li | /image/headImg/1435803983661027330/n02085620-Chihuahuan02085620_2693.jpg | NULL | 2021-09-09 11:15:20 | modelfarm.ai@thundercomm.com | 2022-09-07 08:07:57 |
    +---------------------+------------------------------+----------------+------------------------------------------------------------------+----------+--------+----------+------+------------------------------+-------------+----------+--------+---------------+---------+------+-----------+---------------+------------+----------------+-----------+----------+------------+-----------+--------------------------------------------------------------------------+-----------+---------------------+------------------------------+---------------------+
    8、解决方法
    8.1 更改配置文件相关参数
    net_read_timeout | 30 |--------->120
    | net_write_timeout | 60 --------->240
    max_allowed_packet | 1073741824---->2,147483648
    查询之后依旧报错:
    mysql> select count(1) from sys_user;
    ERROR 2013 (HY000): Lost connection to MySQL server during query
    No connection. Trying to reconnect...
    Connection id: 11
    Current database: moxingbao

    ERROR 2013 (HY000): Lost connection to MySQL server during query
    No connection. Trying to reconnect...
    ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (111)
    ERROR:
    Can't connect to the server

    mysql> select count(1) from sys_user;
    No connection. Trying to reconnect...
    Connection id: 8
    Current database: moxingbao
    8.2 查看后台error日志信息
    2023-10-08T06:54:16.090226Z 11 [ERROR] [MY-011972] [InnoDB] Your database may be corrupt or you may have copied the InnoDB tablespace but not the InnoDB redo log files. Please refer to http://dev.mysql.com/doc/refman/8.1/en/forcing-innodb-recovery.html for information about forcing recovery.
    2023-10-08T06:54:16.090267Z 11 [Warning] [MY-013021] [InnoDB] A transaction id in a record of table `moxingbao`.`sys_invite` is newer than the system-wide maximum.
    2023-10-08T06:54:16.127777Z 11 [ERROR] [MY-011971] [InnoDB] Tablespace 'moxingbao/sys_user' Page [page id: space=23, page number=4] log sequence number 4573384058 is in the future! Current system log sequence number 4545650145.
    2023-10-08T06:54:16.127833Z 11 [ERROR] [MY-011972] [InnoDB] Your database may be corrupt or you may have copied the InnoDB tablespace but not the InnoDB redo log files. Please refer to http://dev.mysql.com/doc/refman/8.1/en/forcing-innodb-recovery.html for information about forcing recovery.
    2023-10-08T06:54:16.127877Z 11 [ERROR] [MY-011971] [InnoDB] Tablespace 'moxingbao/sys_user' Page [page id: space=23, page number=5] log sequence number 4573384058 is in the future! Current system log sequence number 4545650145.
    2023-10-08T06:54:16.127882Z 11 [ERROR] [MY-011972] [InnoDB] Your database may be corrupt or you may have copied the InnoDB tablespace but not the InnoDB redo log files. Please refer to http://dev.mysql.com/doc/refman/8.1/en/forcing-innodb-recovery.html for information about forcing recovery.
    2023-10-08T06:54:16.128130Z 11 [Warning] [MY-013021] [InnoDB] A transaction id in a record of table `moxingbao`.`sys_user` is newer than the system-wide maximum.
    2023-10-08T06:54:16.128151Z 11 [Warning] [MY-013021] [InnoDB] A transaction id in a record of table `moxingbao`.`sys_user` is newer than the system-wide maximum.
    2023-10-08T06:54:16.128201Z 11 [ERROR] [MY-013183] [InnoDB] Assertion failure: trx0rec.cc:579:undo_rec_flags == 0x00 thread 140640253216320

    8.3 这个应该是之前服务器异常断电导致的,配置my.cnf文件
    innodb_force_recovery = 6

    innodb_purge_threads = 1
    9、重启数据库
    这次查询正常

最后修改时间:2023-10-09 11:24:08
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论