1、使用压缩包中的软件进行mysql的安装
2、使用压缩包中的软件进行mysql的安装
-
将rpm包所在目录配置成一个yum仓库
[root@bogon ~]# unzip /root/数据库材料.zip -d /mysql-pkg
[root@bogon ~]# ls /mysql-pkg/
mysql-8.0.36-1.el8.x86_64.rpm-bundle.tar MySQL-Crashcourse.zip
'MySQL Crash Course, 2nd Edition (Forta, Ben) (Z-Library).pdf' mysql-workbench-community-8.0.24-1.el8.x86_64.rpm
[root@bogon mysql-pkg]# mkdir mysql-80
[root@bogon mysql-pkg]# ls
mysql-80 mysql-8.0.36-1.el8.x86_64.rpm-bundle.tar MySQL-Crashcourse.zip mysql-workbench-community-8.0.24-1.el8.x86_64.rpm
[root@bogon mysql-pkg]# tar -xf mysql-8.0.36-1.el8.x86_64.rpm-bundle.tar -C ./mysql-80/
[root@bogon mysql-pkg]# ls ./mysql-80/
mysql-community-client-8.0.36-1.el8.x86_64.rpm mysql-community-libs-8.0.36-1.el8.x86_64.rpm
mysql-community-client-debuginfo-8.0.36-1.el8.x86_64.rpm mysql-community-libs-debuginfo-8.0.36-1.el8.x86_64.rpm
mysql-community-client-plugins-8.0.36-1.el8.x86_64.rpm mysql-community-server-8.0.36-1.el8.x86_64.rpm
mysql-community-client-plugins-debuginfo-8.0.36-1.el8.x86_64.rpm mysql-community-server-debug-8.0.36-1.el8.x86_64.rpm
mysql-community-common-8.0.36-1.el8.x86_64.rpm mysql-community-server-debug-debuginfo-8.0.36-1.el8.x86_64.rpm
mysql-community-debuginfo-8.0.36-1.el8.x86_64.rpm mysql-community-server-debuginfo-8.0.36-1.el8.x86_64.rpm
mysql-community-debugsource-8.0.36-1.el8.x86_64.rpm mysql-community-test-8.0.36-1.el8.x86_64.rpm
mysql-community-devel-8.0.36-1.el8.x86_64.rpm mysql-community-test-debuginfo-8.0.36-1.el8.x86_64.rpm
mysql-community-icu-data-files-8.0.36-1.el8.x86_64.rpm
[root@bogon mysql-pkg]# cd mysql-80/
[root@bogon mysql-80]# pwd
/mysql-pkg/mysql-80
[root@bogon mysql-80]# ls
mysql-community-client-8.0.36-1.el8.x86_64.rpm mysql-community-libs-8.0.36-1.el8.x86_64.rpm
mysql-community-client-debuginfo-8.0.36-1.el8.x86_64.rpm mysql-community-libs-debuginfo-8.0.36-1.el8.x86_64.rpm
mysql-community-client-plugins-8.0.36-1.el8.x86_64.rpm mysql-community-server-8.0.36-1.el8.x86_64.rpm
mysql-community-client-plugins-debuginfo-8.0.36-1.el8.x86_64.rpm mysql-community-server-debug-8.0.36-1.el8.x86_64.rpm
mysql-community-common-8.0.36-1.el8.x86_64.rpm mysql-community-server-debug-debuginfo-8.0.36-1.el8.x86_64.rpm
mysql-community-debuginfo-8.0.36-1.el8.x86_64.rpm mysql-community-server-debuginfo-8.0.36-1.el8.x86_64.rpm
mysql-community-debugsource-8.0.36-1.el8.x86_64.rpm mysql-community-test-8.0.36-1.el8.x86_64.rpm
mysql-community-devel-8.0.36-1.el8.x86_64.rpm mysql-community-test-debuginfo-8.0.36-1.el8.x86_64.rpm
mysql-community-icu-data-files-8.0.36-1.el8.x86_64.rpm
[root@bogon mysql-80]# yum -y install dnf-utils createrepo
[root@bogon mysql-80]# createrepo .
Directory walk started
Directory walk done - 17 packages
Temporary output repo path: ./.repodata/
Preparing sqlite DBs
Pool started (with 5 workers)
Pool finished
[root@bogon mysql-80]# ls
mysql-community-client-8.0.36-1.el8.x86_64.rpm mysql-community-libs-8.0.36-1.el8.x86_64.rpm
mysql-community-client-debuginfo-8.0.36-1.el8.x86_64.rpm mysql-community-libs-debuginfo-8.0.36-1.el8.x86_64.rpm
mysql-community-client-plugins-8.0.36-1.el8.x86_64.rpm mysql-community-server-8.0.36-1.el8.x86_64.rpm
mysql-community-client-plugins-debuginfo-8.0.36-1.el8.x86_64.rpm mysql-community-server-debug-8.0.36-1.el8.x86_64.rpm
mysql-community-common-8.0.36-1.el8.x86_64.rpm mysql-community-server-debug-debuginfo-8.0.36-1.el8.x86_64.rpm
mysql-community-debuginfo-8.0.36-1.el8.x86_64.rpm mysql-community-server-debuginfo-8.0.36-1.el8.x86_64.rpm
mysql-community-debugsource-8.0.36-1.el8.x86_64.rpm mysql-community-test-8.0.36-1.el8.x86_64.rpm
mysql-community-devel-8.0.36-1.el8.x86_64.rpm mysql-community-test-debuginfo-8.0.36-1.el8.x86_64.rpm
mysql-community-icu-data-files-8.0.36-1.el8.x86_64.rpm repodata
[root@bogon mysql-80]# yum-config-manager --add-repo='file:///mysql-pkg/mysql-80' mysql80
Adding repo from: file:///mysql-pkg/mysql-80
[root@bogon mysql-80]# ls /etc/yum.repos.d/
mysql-pkg_mysql-80.repo qh-yum.repo
[root@bogon mysql-80]# vim /etc/yum.repos.d/mysql-pkg_mysql-80.repo
[mysql-pkg_mysql-80]
name=created by dnf config-manager from file:///mysql-pkg/mysql-80
baseurl=file:///mysql-pkg/mysql-80
enabled=1
#### 新增下面这一行
gpgcheck = 0
[root@bogon mysql-80]# yum install mysql-community-server --repo mysql-pkg_mysql-80
## 等待安装完成即可
3、启动服务端守护进程
systemctl start mysqld
[root@bogon ~]# systemctl enable --now mysqld.service
[root@bogon ~]# systemctl status mysqld
● mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: active (running) since Tue 2024-04-02 23:22:30 EDT; 7s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 36725 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
Main PID: 36798 (mysqld)
Status: "Server is operational"
Tasks: 38 (limit: 23330)
Memory: 543.7M
CGroup: /system.slice/mysqld.service
└─36798 /usr/sbin/mysqld
Apr 02 23:22:23 bogon systemd[1]: Starting MySQL Server...
Apr 02 23:22:30 bogon systemd[1]: Started MySQL Server.
[root@bogon ~]# grep password /var/log/m
maillog messages mysqld.log
[root@bogon ~]# grep password /var/log/mysqld.log
2024-04-03T03:22:27.330915Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: +l#RK5yXy<qi
[root@bogon ~]# mysql -u root -p'+l#RK5yXy<qi'
4、连接数据库mysql
[root@bogon ~]# mysql -u root -p'+l#RK5yXy<qi' //使用临时密码登录
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.36
Copyright (c) 2000, 2024, Oracle and/or its affiliates.
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.
mysql> ALTER USER root@localhost IDENTIFIED BY 'Redhat1~'; # 修改密码。临时密码只能登录
Query OK, 0 rows affected (0.01 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.01 sec)
mysql> exit
Bye
[root@bogon ~]# mysql -u root -p'Redhat1~' #验证自定义密码可用
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.36 MySQL Community Server - GPL
Copyright (c) 2000, 2024, Oracle and/or its affiliates.
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.
mysql> show databases; // 查询数据库的数量
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.00 sec)
mysql> exit
Bye