阿里云ECS服务器CentOS8部署MySQL-8.0.21详细步骤
1、查询系统内核版本
[root@localhost opt]# cat /etc/redhat-release;
CentOS Linux release 8.2.2004 (Core)
2、分别执行如下命令安装MySQL的RPM包
官方下载地址,推荐迅雷下载
https://downloads.mysql.com/archives/community/
3、上传、解压rpm包,本文上传rpm包至根目录/opt/下
[root@localhost ~]# cd /opt/
[root@localhost opt]# tar -xvf mysql-8.0.21-1.el8.x86_64.rpm-bundle.tar
[root@localhost opt]# rpm -ivh mysql-community-common-8.0.21-1.el8.x86_64.rpm --nodeps --force
警告:mysql-community-common-8.0.21-1.el8.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY
Verifying... ################################# [100%]
准备中... ################################# [100%]
正在升级/安装...
1:mysql-community-common-8.0.21-1.e################################# [100%]
[root@localhost opt]# rpm -ivh mysql-community-libs-8.0.21-1.el8.x86_64.rpm --nodeps --force;
警告:mysql-community-libs-8.0.21-1.el8.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY
Verifying... ################################# [100%]
准备中... ################################# [100%]
正在升级/安装...
1:mysql-community-libs-8.0.21-1.el8################################# [100%]
[root@localhost opt]# rpm -ivh mysql-community-client-8.0.21-1.el8.x86_64.rpm --nodeps --force
警告:mysql-community-client-8.0.21-1.el8.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY
Verifying... ################################# [100%]
准备中... ################################# [100%]
正在升级/安装...
1:mysql-community-client-8.0.21-1.e################################# [100%]
[root@localhost opt]# rpm -ivh mysql-community-server-8.0.21-1.el8.x86_64.rpm --nodeps --force
警告:mysql-community-server-8.0.21-1.el8.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY
Verifying... ################################# [100%]
准备中... ################################# [100%]
正在升级/安装...
1:mysql-community-server-8.0.21-1.e################################# [100%]
[/usr/lib/tmpfiles.d/mysql.conf:23] Line references path below legacy directory /var/run/, updating /var/run/mysqld → /run/mysqld; please update the tmpfiles.d/ drop-in file accordingly.
[/usr/lib/tmpfiles.d/subscription-manager.conf:1] Line references path below legacy directory /var/run/, updating /var/run/rhsm → /run/rhsm; please update the tmpfiles.d/ drop-in file accordingly.
检查MySQL rpm包是否安装成功
4、初始化数据库
[root@localhost opt]# mkdir -p /usr/local/mysql/data/
[root@localhost opt]# mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data [root@localhost opt]# systemctl start mysqld
[root@localhost opt]# systemctl status mysqld
● mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: active (running) since Thu 2021-04-29 17:17:25 CST; 9s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 34117 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
Main PID: 34224 (mysqld)
Status: "Server is operational"
Tasks: 39 (limit: 11155)
Memory: 427.8M
CGroup: /system.slice/mysqld.service
└─34224 /usr/sbin/mysqld
4月 29 17:17:19 localhost.localdomain systemd[1]: Starting MySQL Server...
4月 29 17:17:25 localhost.localdomain systemd[1]: Started MySQL Server.
5、登录MySQL,修改root密码
[root@localhost opt]# cat /var/log/mysqld.log |grep pass
[root@localhost opt]# mysql -uroot -p
Enter password:KArQmb;pf3W=
mysql> alter user root@localhost identified by 'BHyl@123';
mysql> quit
[root@localhost opt]# mysql -uroot -p
Enter password:BHyl@123
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 12
Server version: 8.0.21 MySQL Community Server - GPL
Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
阿里云ECS服务器CentOS8部署MySQL-8.0.21详细步骤
https://cn.10691.cn//archives/10012