linux CentOS7安装MySQL8.0.28
1.查看系统中是否有会冲突的数据库
CentOS 7.6 默认有个mariadb数据库会和 mysql 冲突
查询命令
rpm -qa|grep mari
mariadb-libs-5.5.68-1.el7.x86_64
删除
rpm -e --nodeps mariadb-libs
rpm -e --nodeps marisa
2.用wget 命令下载安装包
3.用 tar 命令解压
4.用rpm命令安装,注意安装顺序,这个很重要.
rpm -ivh mysql-community-client-8.0.28-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-plugins-8.0.28-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-8.0.28-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-8.0.28-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-8.0.28-1.el7.x86_64.rpm
rpm -ivh mysql-community-icu-data-files-8.0.28-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-8.0.28-1.el7.x86_64.rpm
5.初始化
mysqld --initialize --console
6.修改权限
chown -R mysql:mysql /var/lib/mysql/
7.启动,查看临时密码.测试
-----------------------------------------------------------------------------
下载
[root@VM-4-11-centos mysql]# wget https://downloads.mysql.com/archives/get/p/23/file/mysql-8.0.28-1.el7.x86_64.rpm-bundle.tar
--2022-09-16 12:28:10-- https://downloads.mysql.com/archives/get/p/23/file/mysql-8.0.28-1.el7.x86_64.rpm-bundle.tar
Resolving downloads.mysql.com (downloads.mysql.com)... 104.74.81.249, 2600:1417:e800:18a::2e31, 2600:1417:e800:189::2e31
Connecting to downloads.mysql.com (downloads.mysql.com)|104.74.81.249|:443... connected.
HTTP request sent, awaiting response... 302 Moved Temporarily
Location: https://cdn.mysql.com/archives/mysql-8.0/mysql-8.0.28-1.el7.x86_64.rpm-bundle.tar [following]
--2022-09-16 12:28:11-- https://cdn.mysql.com/archives/mysql-8.0/mysql-8.0.28-1.el7.x86_64.rpm-bundle.tar
Resolving cdn.mysql.com (cdn.mysql.com)... 104.73.0.223
Connecting to cdn.mysql.com (cdn.mysql.com)|104.73.0.223|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 843008000 (804M) [application/x-tar]
Saving to: ‘mysql-8.0.28-1.el7.x86_64.rpm-bundle.tar’
100%[===========================================>] 843,008,000 10.2MB/s in 82s
2022-09-16 12:29:34 (9.83 MB/s) - ‘mysql-8.0.28-1.el7.x86_64.rpm-bundle.tar’ saved [843008000/843008000]
[root@VM-4-11-centos mysql]#
[root@VM-4-11-centos mysql]# ls
mysql-8.0.28-1.el7.x86_64.rpm-bundle.tar mysql-8.0.30-linux-glibc2.12-x86_64.tar.xz
用 tar 命令解压
[root@VM-4-11-centos mysql]# tar -vxf mysql-8.0.28-1.el7.x86_64.rpm-bundle.tar
mysql-community-client-8.0.28-1.el7.x86_64.rpm
mysql-community-client-plugins-8.0.28-1.el7.x86_64.rpm
mysql-community-common-8.0.28-1.el7.x86_64.rpm
mysql-community-devel-8.0.28-1.el7.x86_64.rpm
mysql-community-embedded-compat-8.0.28-1.el7.x86_64.rpm
mysql-community-icu-data-files-8.0.28-1.el7.x86_64.rpm
mysql-community-libs-8.0.28-1.el7.x86_64.rpm
mysql-community-libs-compat-8.0.28-1.el7.x86_64.rpm
mysql-community-server-8.0.28-1.el7.x86_64.rpm
mysql-community-test-8.0.28-1.el7.x86_64.rpm
3.用rpm命令安装,注意安装顺序,这个很重要.
[root@VM-4-11-centos mysql]# rpm -ivh mysql-community-client-8.0.28-1.el7.x86_64.rpm
warning: mysql-community-client-8.0.28-1.el7.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID 3a79bd29: NOKEY
error: Failed dependencies:
mysql-community-client-plugins = 8.0.28-1.el7 is needed by mysql-community-client-8.0.28-1.el7.x86_64
mysql-community-libs(x86-64) >= 8.0.11 is needed by mysql-community-client-8.0.28-1.el7.x86_64
[root@VM-4-11-centos mysql]# rpm -ivh mysql-community-common-8.0.28-1.el7.x86_64.rpm
warning: mysql-community-common-8.0.28-1.el7.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID 3a79bd29: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:mysql-community-common-8.0.28-1.e################################# [100%]
[root@VM-4-11-centos mysql]# rpm -ivh mysql-community-client-plugins-8.0.28-1.el7.x86_64.rpm
warning: mysql-community-client-plugins-8.0.28-1.el7.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID 3a79bd29: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:mysql-community-client-plugins-8.################################# [100%]
[root@VM-4-11-centos mysql]# rpm -ivh mysql-community-libs-8.0.28-1.el7.x86_64.rpm
warning: mysql-community-libs-8.0.28-1.el7.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID 3a79bd29: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:mysql-community-libs-8.0.28-1.el7################################# [100%]
[root@VM-4-11-centos mysql]# rpm -ivh mysql-community-client-8.0.28-1.el7.x86_64.rpm
warning: mysql-community-client-8.0.28-1.el7.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID 3a79bd29: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:mysql-community-client-8.0.28-1.e################################# [100%]
[root@VM-4-11-centos mysql]# rpm -ivh mysql-community-icu-data-files-8.0.28-1.el7.x86_64.rpm
warning: mysql-community-icu-data-files-8.0.28-1.el7.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID 3a79bd29: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:mysql-community-icu-data-files-8.################################# [100%]
[root@VM-4-11-centos mysql]# rpm -ivh mysql-community-server-8.0.28-1.el7.x86_64.rpm
warning: mysql-community-server-8.0.28-1.el7.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID 3a79bd29: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:mysql-community-server-8.0.28-1.e################################# [100%]
[root@VM-4-11-centos mysql]# mysqld --initialize --console
[root@VM-4-11-centos mysql]# chown -R mysql:mysql /var/lib/mysql/
[root@VM-4-11-centos mysql]# systemctl start mysqld
查看临时密码
[root@VM-4-11-centos mysql]# cat /var/log/mysqld.log | grep localhost
2022-09-17T06:34:34.838852Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: QSpGYTk+T5dh