CentOS7系列--使用yum安装MySQL8.0

举报
郁唯xiaolin 发表于 2021/05/22 09:40:25 2021/05/22
【摘要】 本文主要涉及mysql8.0的yum安装以及修改密码,还有降版本碰到的一个问题“InnoDB: Invalid flags 0x4800 in ./ibdata1”

本文主要涉及mysql8.0的yum安装以及修改密码

一、yum安装mysql

cd /usr/local/src/
# 下载mysql80的rpm仓库源
wget https://repo.mysql.com/mysql80-community-release-el7.rpm
# 安装mysql8.0源
yum -y install ./mysql80-community-release-el7.rpm
# 
yum makecache fast
 #查看正在使用的MySQL repo
yum repolist all|grep mysql
​
# 安装MySQL80
yum install -y mysql-community-common mysql-community-libs mysql-community-libs-compat mysql-community-client mysql-community-server
​
# 设置 mysql 开机启动
systemctl enable mysqld
​
#  启动mysql
systemctl start mysqld

二、登录mysql 并修改密码

初始安装mysql的密码保存在/var/log/mysqld.log中,使用命令查找密码如下:

 ~]# grep password /var/log/mysqld.log 
2021-04-24T00:05:59.134760Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: vvlJb:iSx4?6

密码就在行末尾,使用此密码即可登录mysql,不过不安全,需要自行修改密码,修改命令如下:

mysqladmin -u root password Dear@123456! -p vvlJb:iSx4?6

当然,也可以登录之后,使用alter命令进行修改:

alter user root@localhost identified by 'Dear@123456!';

至此mysql安装完成。


三、记录一个安装启动时候的报错

安装完成,使用命令启动时,发现启动失败,使用命令“journalctl -xe”查看失败原因如下:

my.cnf.d]# journalctl -xe
Apr 24 08:33:16 hw-1-8 mariadbd[13864]: 2021-04-24  8:33:16 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
Apr 24 08:33:16 hw-1-8 mariadbd[13864]: 2021-04-24  8:33:16 0 [Note] Plugin 'FEEDBACK' is disabled.
Apr 24 08:33:16 hw-1-8 mariadbd[13864]: 2021-04-24  8:33:16 0 [ERROR] Could not open mysql.plugin table: "Table 'mysql.plugin' doesn't exist".
Apr 24 08:33:16 hw-1-8 mariadbd[13864]: 2021-04-24  8:33:16 0 [ERROR] Unknown/unsupported storage engine: InnoDB
Apr 24 08:33:16 hw-1-8 mariadbd[13864]: 2021-04-24  8:33:16 0 [ERROR] Aborting
Apr 24 08:33:17 hw-1-8 systemd[1]: mariadb.service: main process exited, code=exited, status=1/FAILURE
Apr 24 08:33:17 hw-1-8 systemd[1]: Failed to start MariaDB 10.5.9 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.
Apr 24 08:33:17 hw-1-8 systemd[1]: Unit mariadb.service entered failed state.
=====================此处省略若干========================
Apr 24 08:36:14 hw-1-8 mariadbd[13946]: 2021-04-24  8:36:14 0 [Note] /usr/sbin/mariadbd (mysqld 10.5.9-MariaDB) starting as process 13946 ...
Apr 24 08:36:14 hw-1-8 mariadbd[13946]: 2021-04-24  8:36:14 0 [Warning] Could not increase number of max_open_files to more than 16384 (reques
Apr 24 08:36:14 hw-1-8 mariadbd[13946]: 2021-04-24  8:36:14 0 [Note] InnoDB: Uses event mutexes
Apr 24 08:36:14 hw-1-8 mariadbd[13946]: 2021-04-24  8:36:14 0 [Note] InnoDB: Compressed tables use zlib 1.2.7
Apr 24 08:36:14 hw-1-8 mariadbd[13946]: 2021-04-24  8:36:14 0 [Note] InnoDB: Number of pools: 1
Apr 24 08:36:14 hw-1-8 mariadbd[13946]: 2021-04-24  8:36:14 0 [Note] InnoDB: Using crc32 + pclmulqdq instructions
Apr 24 08:36:14 hw-1-8 mariadbd[13946]: 2021-04-24  8:36:14 0 [Note] InnoDB: Using Linux native AIO
Apr 24 08:36:14 hw-1-8 mariadbd[13946]: 2021-04-24  8:36:14 0 [Note] InnoDB: Initializing buffer pool, total size = 134217728, chunk size = 13
Apr 24 08:36:14 hw-1-8 mariadbd[13946]: 2021-04-24  8:36:14 0 [Note] InnoDB: Completed initialization of buffer pool
Apr 24 08:36:14 hw-1-8 mariadbd[13946]: 2021-04-24  8:36:14 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread p
Apr 24 08:36:14 hw-1-8 mariadbd[13946]: 2021-04-24  8:36:14 0 [ERROR] InnoDB: Invalid flags 0x4800 in ./ibdata1
Apr 24 08:36:14 hw-1-8 mariadbd[13946]: 2021-04-24  8:36:14 0 [ERROR] InnoDB: Plugin initialization aborted with error Data structure corrupti
Apr 24 08:36:14 hw-1-8 mariadbd[13946]: 2021-04-24  8:36:14 0 [Note] InnoDB: Starting shutdown...
Apr 24 08:36:14 hw-1-8 mariadbd[13946]: 2021-04-24  8:36:14 0 [ERROR] Plugin 'InnoDB' init function returned error.
Apr 24 08:36:14 hw-1-8 mariadbd[13946]: 2021-04-24  8:36:14 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
Apr 24 08:36:14 hw-1-8 mariadbd[13946]: 2021-04-24  8:36:14 0 [Note] Plugin 'FEEDBACK' is disabled.
Apr 24 08:36:14 hw-1-8 mariadbd[13946]: 2021-04-24  8:36:14 0 [ERROR] Could not open mysql.plugin table: "Table 'mysql.plugin' doesn't exist".
Apr 24 08:36:14 hw-1-8 mariadbd[13946]: 2021-04-24  8:36:14 0 [ERROR] Unknown/unsupported storage engine: InnoDB
Apr 24 08:36:14 hw-1-8 mariadbd[13946]: 2021-04-24  8:36:14 0 [ERROR] Aborting
Apr 24 08:36:14 hw-1-8 systemd[1]: mariadb.service: main process exited, code=exited, status=1/FAILURE
Apr 24 08:36:14 hw-1-8 systemd[1]: Failed to start MariaDB 10.5.9 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.
Apr 24 08:36:14 hw-1-8 systemd[1]: Unit mariadb.service entered failed state.
Apr 24 08:36:14 hw-1-8 systemd[1]: mariadb.service failed.
Apr 24 08:36:14 hw-1-8 polkitd[769]: Unregistered Authentication Agent for unix-process:13926:320856 (system bus name :1.68, object path /org/
Apr 24 08:36:17 hw-1-8 sshd[13954]: Did not receive identification string from


从上面报错内容中发现“ InnoDB: Invalid flags 0x4800 in ./ibdata1”这样的报错,百度查找了原因,说是:高版本数据库时创建的一些数据库数据都还在,使用的是高版本的InnoDB引擎,而低版本的数据库服务还是指向了这些数据,但是一些版本的数据格式不同,这个时候,我们只要把高版本的数据删掉就可以了,删掉后重新启动mysql就可以了。

当然,解决问题,如果是全新安装,可以采用这种形式,如果是降级安装,则需要将数据备份出来,然后在删除目录,重新启动。


以上是yum 安装的过程。 当然,不满足于rpm安装的,可以自行编译安装。

还有小伙伴可能对主从,备份等感兴趣,敬请参考其他文档。

【版权声明】本文为华为云社区用户原创内容,转载时必须标注文章的来源(华为云社区)、文章链接、文章作者等基本信息, 否则作者和本社区有权追究责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。