b2b电商系统搭建的关键步骤与最佳实践解析,助力企业数字化转型
963
2022-05-30
本文主要涉及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安装的,可以自行编译安装。
还有小伙伴可能对主从,备份等感兴趣,敬请参考其他文档。
CentOS MySQL yum
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。