【操作记录】Linux服务器上安装MySQL

查看Linux内核(el7)

[root@iZaeyhb2zzq0bnZ mysql]# cat /proc/version
Linux version 3.10.0-1160.90.1.el7.x86_64 (mockbuild@kbuilder.bsys.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC) ) #1 SMP Thu May          4 15:21:22 UTC 2023
[root@iZaeyhb2zzq0bnZ mysql]# 

查询软件包(el7)

[root@iZaeyhb2zzq0bnZ mysql]# yum list mysql-community-server
Loaded plugins: fastestmirror, product-id, search-disabled-repos, subscription-manager

This system is not registered with an entitlement server. You can use subscription-manager to register.

Loading mirror speeds from cached hostfile
Available Packages
mysql-community-server.x86_64                            8.0.34-1.el7                             mysql80-community
[root@iZaeyhb2zzq0bnZ mysql]# 

下载yum源

下载yum源
下载yum源

上传至服务器(自定义位置)

上传至服务器

未配置源时下载不了

[root@iZaeyhb2zzq0bnZ mysql]# yum install mysql-community-server
Loaded plugins: fastestmirror, product-id, search-disabled-repos, subscription-manager

This system is not registered with an entitlement server. You can use subscription-manager to register.

Loading mirror speeds from cached hostfile
No package mysql-community-server available.
Error: Nothing to do
[root@iZaeyhb2zzq0bnZ mysql]# 

配置源mysql80-community-release-el7-9.noarch.rpm

[root@iZaeyhb2zzq0bnZ mysql]# rpm -ivh mysql80-community-release-el7-9.noarch.rpm
warning: mysql80-community-release-el7-9.noarch.rpm: Header V4 RSA/SHA256 Signature, key ID 3a79bd29: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:mysql80-community-release-el7-9  ################################# [100%]
[root@iZaeyhb2zzq0bnZ mysql]# rpm -ql mysql80-community-release-el7-9.noarch
/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql-2022
/etc/yum.repos.d/mysql-community-debuginfo.repo
/etc/yum.repos.d/mysql-community-source.repo
/etc/yum.repos.d/mysql-community.repo
[root@iZaeyhb2zzq0bnZ mysql]# rpm -qi mysql80-community-release-el7-9.noarch
Name        : mysql80-community-release
Version     : el7
Release     : 9
Architecture: noarch
Install Date: Wed 09 Aug 2023 11:37:45 PM CST
Group       : System Environment/Base
Size        : 12597
License     : GPLv2
Signature   : RSA/SHA256, Wed 26 Jul 2023 02:40:58 AM CST, Key ID 467b942d3a79bd29
Source RPM  : mysql80-community-release-el7-9.src.rpm
Build Date  : Wed 26 Jul 2023 01:05:28 AM CST
Build Host  : pb2-el7-01.regionaliad02.mysql2iad.oraclevcn.com
Relocations : (not relocatable)
Packager    : MySQL Release Engineering <mysql-build@oss.oracle.com>
Vendor      : MySQL
URL         : http://dev.mysql.com
Summary     : MySQL repository configuration for yum
Description :
Package for installation of setup/configuration files required for
installation of MySQL packages by yum.
[root@iZaeyhb2zzq0bnZ mysql]# 

显示已配置的源

[root@iZaeyhb2zzq0bnZ mysql]# yum repolist all | grep mysql
mysql-cluster-7.5-community/x86_64                  MySQL Cluste disabled
mysql-cluster-7.5-community-source                  MySQL Cluste disabled
mysql-cluster-7.6-community/x86_64                  MySQL Cluste disabled
mysql-cluster-7.6-community-source                  MySQL Cluste disabled
mysql-cluster-8.0-community/x86_64                  MySQL Cluste disabled
mysql-cluster-8.0-community-debuginfo/x86_64        MySQL Cluste disabled
mysql-cluster-8.0-community-source                  MySQL Cluste disabled
mysql-cluster-innovation-community/x86_64           MySQL Cluste disabled
mysql-cluster-innovation-community-debuginfo/x86_64 MySQL Cluste disabled
mysql-cluster-innovation-community-source           MySQL Cluste disabled
mysql-connectors-community/x86_64                   MySQL Connec enabled:    227
mysql-connectors-community-debuginfo/x86_64         MySQL Connec disabled
mysql-connectors-community-source                   MySQL Connec disabled
mysql-innovation-community/x86_64                   MySQL Innova disabled
mysql-innovation-community-debuginfo/x86_64         MySQL Innova disabled
mysql-innovation-community-source                   MySQL Innova disabled
mysql-tools-community/x86_64                        MySQL Tools  enabled:    100
mysql-tools-community-debuginfo/x86_64              MySQL Tools  disabled
mysql-tools-community-source                        MySQL Tools  disabled
mysql-tools-innovation-community/x86_64             MySQL Tools  disabled
mysql-tools-innovation-community-debuginfo/x86_64   MySQL Tools  disabled
mysql-tools-innovation-community-source             MySQL Tools  disabled
mysql-tools-preview/x86_64                          MySQL Tools  disabled
mysql-tools-preview-source                          MySQL Tools  disabled
mysql57-community/x86_64                            MySQL 5.7 Co disabled
mysql57-community-source                            MySQL 5.7 Co disabled
mysql80-community/x86_64                            MySQL 8.0 Co enabled:    425
mysql80-community-debuginfo/x86_64                  MySQL 8.0 Co disabled
mysql80-community-source                            MySQL 8.0 Co disabled
[root@iZaeyhb2zzq0bnZ mysql]# 

安装mysql-community-server

[root@iZaeyhb2zzq0bnZ mysql]# yum install mysql-community-server
Loaded plugins: fastestmirror, product-id, search-disabled-repos, subscription-manager

This system is not registered with an entitlement server. You can use subscription-manager to register.

Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package mysql-community-server.x86_64 0:8.0.34-1.el7 will be installed
--> Processing Dependency: mysql-community-common(x86-64) = 8.0.34-1.el7 for package: mysql-community-server-8.0.34                                           -1.el7.x86_64
--> Processing Dependency: mysql-community-icu-data-files = 8.0.34-1.el7 for package: mysql-community-server-8.0.34                                           -1.el7.x86_64
--> Processing Dependency: mysql-community-client(x86-64) >= 8.0.11 for package: mysql-community-server-8.0.34-1.el                                           7.x86_64
--> Running transaction check
---> Package mysql-community-client.x86_64 0:8.0.34-1.el7 will be installed
--> Processing Dependency: mysql-community-client-plugins = 8.0.34-1.el7 for package: mysql-community-client-8.0.34                                           -1.el7.x86_64
--> Processing Dependency: mysql-community-libs(x86-64) >= 8.0.11 for package: mysql-community-client-8.0.34-1.el7.                                           x86_64
---> Package mysql-community-common.x86_64 0:8.0.34-1.el7 will be installed
---> Package mysql-community-icu-data-files.x86_64 0:8.0.34-1.el7 will be installed
--> Running transaction check
---> Package mariadb-libs.x86_64 1:5.5.68-1.el7 will be obsoleted
--> Processing Dependency: libmysqlclient.so.18()(64bit) for package: 2:postfix-2.10.1-9.el7.x86_64
--> Processing Dependency: libmysqlclient.so.18(libmysqlclient_18)(64bit) for package: 2:postfix-2.10.1-9.el7.x86_6                                           4
---> Package mysql-community-client-plugins.x86_64 0:8.0.34-1.el7 will be installed
---> Package mysql-community-libs.x86_64 0:8.0.34-1.el7 will be obsoleting
--> Running transaction check
---> Package mysql-community-libs-compat.x86_64 0:8.0.34-1.el7 will be obsoleting
--> Finished Dependency Resolution

Dependencies Resolved

===================================================================================================================
 Package                                 Arch            Version                  Repository                  Size
===================================================================================================================
Installing:
 mysql-community-libs                    x86_64          8.0.34-1.el7             mysql80-community          1.5 M
     replacing  mariadb-libs.x86_64 1:5.5.68-1.el7
 mysql-community-libs-compat             x86_64          8.0.34-1.el7             mysql80-community          669 k
     replacing  mariadb-libs.x86_64 1:5.5.68-1.el7
 mysql-community-server                  x86_64          8.0.34-1.el7             mysql80-community           64 M
Installing for dependencies:
 mysql-community-client                  x86_64          8.0.34-1.el7             mysql80-community           16 M
 mysql-community-client-plugins          x86_64          8.0.34-1.el7             mysql80-community          3.6 M
 mysql-community-common                  x86_64          8.0.34-1.el7             mysql80-community          666 k
 mysql-community-icu-data-files          x86_64          8.0.34-1.el7             mysql80-community          2.2 M

Transaction Summary
===================================================================================================================
Install  3 Packages (+4 Dependent packages)

Total download size: 89 M
Is this ok [y/d/N]: y
Downloading packages:
warning: /var/cache/yum/x86_64/7/mysql80-community/packages/mysql-community-client-plugins-8.0.34-1.el7.x86_64.rpm: Header V4 RSA/SHA256 Signature, k         ey ID 3a79bd29: NOKEY
Public key for mysql-community-client-plugins-8.0.34-1.el7.x86_64.rpm is not installed
(1/7): mysql-community-client-plugins-8.0.34-1.el7.x86_64.rpm                                                                 | 3.6 MB  00:00:21
(2/7): mysql-community-common-8.0.34-1.el7.x86_64.rpm                                                                         | 666 kB  00:00:04
(3/7): mysql-community-icu-data-files-8.0.34-1.el7.x86_64.rpm                                                                 | 2.2 MB  00:00:12
(4/7): mysql-community-libs-8.0.34-1.el7.x86_64.rpm                                                                           | 1.5 MB  00:00:08
(5/7): mysql-community-libs-compat-8.0.34-1.el7.x86_64.rpm                                                                    | 669 kB  00:00:07
(6/7): mysql-community-client-8.0.34-1.el7.x86_64.rpm                                                                         |  16 MB  00:01:39
(7/7): mysql-community-server-8.0.34-1.el7.x86_64.rpm                                                                         |  64 MB  00:07:13
-----------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                186 kB/s |  89 MB  00:08:08
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql-2022
Importing GPG key 0x3A79BD29:
 Userid     : "MySQL Release Engineering <mysql-build@oss.oracle.com>"
 Fingerprint: 859b e8d7 c586 f538 430b 19c2 467b 942d 3a79 bd29
 Package    : mysql80-community-release-el7-9.noarch (installed)
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql-2022
Is this ok [y/N]: y
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Importing GPG key 0x5072E1F5:
 Userid     : "MySQL Release Engineering <mysql-build@oss.oracle.com>"
 Fingerprint: a4a9 4068 76fc bd3c 4567 70c8 8c71 8d3b 5072 e1f5
 Package    : mysql80-community-release-el7-9.noarch (installed)
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Is this ok [y/N]: y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : mysql-community-common-8.0.34-1.el7.x86_64                                                                                        1/8
  Installing : mysql-community-client-plugins-8.0.34-1.el7.x86_64                                                                                2/8
  Installing : mysql-community-libs-8.0.34-1.el7.x86_64                                                                                          3/8
  Installing : mysql-community-client-8.0.34-1.el7.x86_64                                                                                        4/8
  Installing : mysql-community-icu-data-files-8.0.34-1.el7.x86_64                                                                                5/8
  Installing : mysql-community-server-8.0.34-1.el7.x86_64                                                                                        6/8
  Installing : mysql-community-libs-compat-8.0.34-1.el7.x86_64                                                                                   7/8
  Erasing    : 1:mariadb-libs-5.5.68-1.el7.x86_64                                                                                                8/8
  Verifying  : mysql-community-server-8.0.34-1.el7.x86_64                                                                                        1/8
  Verifying  : mysql-community-client-plugins-8.0.34-1.el7.x86_64                                                                                2/8
  Verifying  : mysql-community-icu-data-files-8.0.34-1.el7.x86_64                                                                                3/8
  Verifying  : mysql-community-common-8.0.34-1.el7.x86_64                                                                                        4/8
  Verifying  : mysql-community-libs-8.0.34-1.el7.x86_64                                                                                          5/8
  Verifying  : mysql-community-libs-compat-8.0.34-1.el7.x86_64                                                                                   6/8
  Verifying  : mysql-community-client-8.0.34-1.el7.x86_64                                                                                        7/8
  Verifying  : 1:mariadb-libs-5.5.68-1.el7.x86_64                                                                                                8/8

Installed:
  mysql-community-libs.x86_64 0:8.0.34-1.el7    mysql-community-libs-compat.x86_64 0:8.0.34-1.el7    mysql-community-server.x86_64 0:8.0.34-1.el7

Dependency Installed:
  mysql-community-client.x86_64 0:8.0.34-1.el7                          mysql-community-client-plugins.x86_64 0:8.0.34-1.el7
  mysql-community-common.x86_64 0:8.0.34-1.el7                          mysql-community-icu-data-files.x86_64 0:8.0.34-1.el7

Replaced:
  mariadb-libs.x86_64 1:5.5.68-1.el7

Complete!
[root@iZaeyhb2zzq0bnZ mysql]# 

查看初始密码

[root@iZaeyhb2zzq0bnZ mysql]# less /var/log/mysqld.log

通过初始密码登录后不可操 需要修改密码

[root@iZaeyhb2zzq0bnZ mysql]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.34

Copyright (c) 2000, 2023, 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;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql> 

密码修改过于简单会报错

mysql> alter user 'root'@'localhost' identified by '';
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
mysql> 

完成

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.00 sec)

mysql> 

👉 建库
👉 建表
👉 【操作记录】Linux服务器上安装jdk

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值