一、环境部署
1、红帽为:Red Hat Enterprise Linux 9.3 64 位
如果之前安装过本地镜像版本的MySQL软件,请先删除之前的安装
[root@localhost ~]# dnf remove mysql-server -y
[root@localhost ~]# rm -rf /var/lib/mysql
[root@localhost ~]# rm -rf /var/log/mysql
[root@localhost ~]# userdel -r mysql
二、 查找MySQL的命令
[root@localhost ~] # dnf repolist enabled | grep mysqlmysql-connectors-community MySQL Connectors Communitymysql-tools-community MySQL Tools Communitymysql80-community MySQL 8 .0 Community Server
三、 安装MySQL服务器
[root@localhost ~] # dnf install mysql-server -y结果:Updating Subscription Management repositories.Unable to read consumer identityThis system is not registered with an entitlement server. You can usesubscription-manager to register.Last metadata expiration check: 5 :09:04 ago on Wed 03 Jan 2024 11 :28:41 AM CST.Dependencies resolved.======================================================================================================================Package Architecture VersionRepository Size======================================================================================================================Installing: mysql-community-server x86_64 8 .0.35-1.el9mysql80-community 49 MInstalling dependencies:mysql-community-client x86_64 8 .0.35-1.el9mysql80-community 3 .5 Mmysql-community-client-plugins x86_64 8 .0.35-1.el9mysql80-community 1 .4 Mmysql-community-common x86_64 8 .0.35-1.el9mysql80-community 557 kmysql-community-icu-data-files x86_64 8 .0.35-1.el9mysql80-community 2 .3 Mmysql-community-libs x86_64 8 .0.35-1.el9mysql80-community 1 .4 MTransaction Summary======================================================================================================================Install 6 PackagesTotal download size: 58 MInstalled size: 334 MDownloading Packages:(1/6): mysql-community-common-8.0.35-1.el9.x86_64.rpm246 kB/s | 557 kB 00 :02(2/6): mysql-community-client-plugins-8.0.35-1.el9.x86_64.rpm611 kB/s | 1 .4 MB 00 :02(3/6): mysql-community-libs-8.0.35-1.el9.x86_64.rpm2 .5 MB/s | 1 .4 MB 00 :00(4/6): mysql-community-icu-data-files-8.0.35-1.el9.x86_64.rpm2 .1 MB/s | 2 .3 MB 00 :01(5/6): mysql-community-client-8.0.35-1.el9.x86_64.rpm733 kB/s | 3 .5 MB 00 :04(6/6): mysql-community-server-8.0.35-1.el9.x86_64.rpm6 .7 MB/s | 49 MB 00 :07----------------------------------------------------------------------------------------------------------------------Total5 .7 MB/s | 58 MB 00 :10MySQL 8 .0 Community Server2 .9 MB/s | 3 .1 kB 00 :00Importing GPG key 0xA8D3785C:Userid : "MySQL Release Engineering <mysql-build@oss.oracle.com>"Fingerprint: BCA4 3417 C3B4 85DD 128E C6D4 B7B3 B788 A8D3 785CFrom : /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql-2023Key imported successfullyMySQL 8 .0 Community Server2 .0 MB/s | 3 .1 kB 00 :00Importing GPG key 0x3A79BD29:Userid : "MySQL Release Engineering <mysql-build@oss.oracle.com>"Fingerprint: 859B E8D7 C586 F538 430B 19C2 467B 942D 3A79 BD29From : /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql-2022Key imported successfullyRunning transaction checkTransaction check succeeded.Running transaction testTransaction test succeeded. Running transactionPreparing :1 /1Installing : mysql-community-common-8.0.35-1.el9.x86_641 /6Installing : mysql-community-client-plugins-8.0.35-1.el9.x86_642 /6Installing : mysql-community-libs-8.0.35-1.el9.x86_643 /6Running scriptlet: mysql-community-libs-8.0.35-1.el9.x86_643 /6Installing : mysql-community-client-8.0.35-1.el9.x86_644 /6Installing : mysql-community-icu-data-files-8.0.35-1.el9.x86_645 /6Running scriptlet: mysql-community-server-8.0.35-1.el9.x86_646 /6Installing : mysql-community-server-8.0.35-1.el9.x86_646 /6Running scriptlet: mysql-community-server-8.0.35-1.el9.x86_646 /6Verifying : mysql-community-client-8.0.35-1.el9.x86_641 /6Verifying : mysql-community-client-plugins-8.0.35-1.el9.x86_642 /6Verifying : mysql-community-common-8.0.35-1.el9.x86_643 /6Verifying : mysql-community-icu-data-files-8.0.35-1.el9.x86_644 /6Verifying : mysql-community-libs-8.0.35-1.el9.x86_645 /6Verifying : mysql-community-server-8.0.35-1.el9.x86_646 /6Installed products updated.Installed:mysql-community-client-8.0.35-1.el9.x86_64 mysql-community-clientplugins-8.0.35-1.el9.x86_64mysql-community-common-8.0.35-1.el9.x86_64 mysql-community-icu-datafiles-8.0.35-1.el9.x86_64mysql-community-libs-8.0.35-1.el9.x86_64 mysql-community-server-8.0.35-1.el9.x86_64Complete!当看到completel表示完成。
四、启动
[root@localhost ~]# systemctl start mysqld
五、查看密钥
2024-01-03T08:38:42.943965Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: t5BLwdq*orTp
六、登录MySQL
[root@localhost ~] # mysql -uroot -pEnter password:
七、输入密钥
Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 9Server version: 8 .0.35Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql>
八、改密码
mysql> ALTER USER 'root' @ 'localhost' IDENTIFIED BY 'MyNewPass4!' ;
完成