centos中mysql8安装

mysql安装

查看是否安装mysql

[root@iZ2zeh3bjq6rgnw0phucy7Z /]# rpm -qa | grep -i  mysql
mysql-8.0.26-1.module_el8.4.0+915+de215114.x86_64
mysql57-community-release-el7-10.noarch
mysql-common-8.0.26-1.module_el8.4.0+915+de215114.x86_64

去除相关文件

[root@iZ2zeh3bjq6rgnw0phucy7Z /]#yum remove mysql-8.0.261.module_el8.4.0+915+de215114.x86_64
Invalid configuration value: failovermethod=priority in /etc/yum.repos.d/CentOS-epel.repo; Configuration: OptionBinding with id "failovermethod" does not exist
Modular dependency problems:

 Problem 1: conflicting requests
  - nothing provides module(perl:5.26) needed by module perl-IO-Socket-SSL:2.066:8030020201222215140:1e4bbb35.x86_64
 Problem 2: conflicting requests
  - nothing provides module(perl:5.26) needed by module perl-libwww-perl:6.34:8030020201223164340:b967a9a2.x86_64
Dependencies resolved.
============================================================================================================================
 Package                            Architecture   Version                                         Repository          Size
============================================================================================================================
Removing:
 mysql                              x86_64         8.0.26-1.module_el8.4.0+915+de215114            @appstream          63 M
Removing unused dependencies:
 mariadb-connector-c-config         noarch         3.1.11-2.el8_3                                  @appstream         497  
 mysql-common                       x86_64         8.0.26-1.module_el8.4.0+915+de215114            @appstream         460 k

Transaction Summary
============================================================================================================================
Remove  3 Packages

Freed space: 63 M
Is this ok [y/N]: y
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                    1/1 
  Erasing          : mysql-8.0.26-1.module_el8.4.0+915+de215114.x86_64                                                  1/3 
  Erasing          : mysql-common-8.0.26-1.module_el8.4.0+915+de215114.x86_64                                           2/3 
  Erasing          : mariadb-connector-c-config-3.1.11-2.el8_3.noarch                                                   3/3 
  Running scriptlet: mariadb-connector-c-config-3.1.11-2.el8_3.noarch                                                   3/3 
  Verifying        : mariadb-connector-c-config-3.1.11-2.el8_3.noarch                                                   1/3 
  Verifying        : mysql-8.0.26-1.module_el8.4.0+915+de215114.x86_64                                                  2/3 
  Verifying        : mysql-common-8.0.26-1.module_el8.4.0+915+de215114.x86_64                                           3/3 

Removed:
  mariadb-connector-c-config-3.1.11-2.el8_3.noarch                 mysql-8.0.26-1.module_el8.4.0+915+de215114.x86_64        
  mysql-common-8.0.26-1.module_el8.4.0+915+de215114.x86_64        

Complete!

查找与之相匹配的文件 并去除

[root@iZ2zeh3bjq6rgnw0phucy7Z /]# find / -name mysql
/var/lib/selinux/targeted/active/modules/100/mysql
/usr/share/bash-completion/completions/mysql
/usr/share/selinux/targeted/default/active/modules/100/mysql
[root@iZ2zeh3bjq6rgnw0phucy7Z /]# rm -rf /var/lib/selinux/targeted/active/modules/100/mysql
[root@iZ2zeh3bjq6rgnw0phucy7Z /]# rm -rf /usr/share/bash-completion/completions/mysql
[root@iZ2zeh3bjq6rgnw0phucy7Z /]# rm -rf /usr/share/selinux/targeted/default/active/modules/100/mysql
[root@iZ2zeh3bjq6rgnw0phucy7Z /]# find / -name mysql
[root@iZ2zeh3bjq6rgnw0phucy7Z /]# rpm -qa | grep -i  mariadb

切换到安装目录并新建mysql文件夹

[root@iZ2zeh3bjq6rgnw0phucy7Z local]# ls
aegis  bin  etc  games  include  lib  lib64  libexec  sbin  share  src
[root@iZ2zeh3bjq6rgnw0phucy7Z local]# mkdir mysql
[root@iZ2zeh3bjq6rgnw0phucy7Z local]# ls
aegis  bin  etc  games  include  lib  lib64  libexec  mysql  sbin  share  src
[root@iZ2zeh3bjq6rgnw0phucy7Z local]# cd mysql

开始安装mysql

[root@iZ2zeh3bjq6rgnw0phucy7Z mysql]# wget https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm
--2021-12-17 15:48:11--  https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm
Resolving dev.mysql.com (dev.mysql.com)... 137.254.60.11
Connecting to dev.mysql.com (dev.mysql.com)|137.254.60.11|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://repo.mysql.com//mysql80-community-release-el7-1.noarch.rpm [following]
--2021-12-17 15:48:12--  https://repo.mysql.com//mysql80-community-release-el7-1.noarch.rpm
Resolving repo.mysql.com (repo.mysql.com)... 23.59.157.177
Connecting to repo.mysql.com (repo.mysql.com)|23.59.157.177|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 25820 (25K) [application/x-redhat-package-manager]
Saving to: ‘mysql80-community-release-el7-1.noarch.rpm’

mysql80-community-release-el7- 100%[====================================================>]  25.21K   131KB/s    in 0.2s    

2021-12-17 15:48:13 (131 KB/s) - ‘mysql80-community-release-el7-1.noarch.rpm’ saved [25820/25820]

[root@iZ2zeh3bjq6rgnw0phucy7Z mysql]# ll
total 28
-rw-r--r-- 1 root root 25820 Apr 18  2018 mysql80-community-release-el7-1.noarch.rpm

安装mysql80-community-release

[root@iZ2zeh3bjq6rgnw0phucy7Z mysql]# rpm -qpl mysql80-community-release-el7-1.noarch.rpm
warning: mysql80-community-release-el7-1.noarch.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
/etc/yum.repos.d/mysql-community-source.repo
/etc/yum.repos.d/mysql-community.repo
[root@iZ2zeh3bjq6rgnw0phucy7Z mysql]# rpm -ivh mysql80-community-release-el7-1.noarch.rpm
warning: mysql80-community-release-el7-1.noarch.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Verifying...                          ################################# [100%]
Preparing...                          ################################# [100%]
Updating / installing...
   1:mysql80-community-release-el7-1  ################################# [100%]
[root@iZ2zeh3bjq6rgnw0phucy7Z mysql]# yum list installed | grep mysql(查看安装mysql安装状态)
Invalid configuration value: failovermethod=priority in /etc/yum.repos.d/CentOS-epel.repo; Configuration: OptionBinding with id "failovermethod" does not exist
Modular dependency problems:

 Problem 1: conflicting requests
  - nothing provides module(perl:5.26) needed by module perl-IO-Socket-SSL:2.066:8030020201222215140:1e4bbb35.x86_64
 Problem 2: conflicting requests
  - nothing provides module(perl:5.26) needed by module perl-libwww-perl:6.34:8030020201223164340:b967a9a2.x86_64
mysql80-community-release.noarch     el7-1

显示所有启用的mysql,显示所有启用的mysql

yum repolist all | grep mysql
Invalid configuration value: failovermethod=priority in /etc/yum.repos.d/CentOS-epel.repo; Configuration: OptionBinding with id "failovermethod" does not exist
mysql-cluster-7.5-community        MySQL Cluster 7.5 Community          disabled
mysql-cluster-7.5-community-source MySQL Cluster 7.5 Community - Source disabled
mysql-cluster-7.6-community        MySQL Cluster 7.6 Community          disabled
mysql-cluster-7.6-community-source MySQL Cluster 7.6 Community - Source disabled
mysql-connectors-community         MySQL Connectors Community           enabled
mysql-connectors-community-source  MySQL Connectors Community - Source  disabled
mysql-tools-community              MySQL Tools Community                enabled
mysql-tools-community-source       MySQL Tools Community - Source       disabled
mysql-tools-preview                MySQL Tools Preview                  disabled
mysql-tools-preview-source         MySQL Tools Preview - Source         disabled
mysql55-community                  MySQL 5.5 Community Server           disabled
mysql55-community-source           MySQL 5.5 Community Server - Source  disabled
mysql56-community                  MySQL 5.6 Community Server           disabled
mysql56-community-source           MySQL 5.6 Community Server - Source  disabled
mysql57-community                  MySQL 5.7 Community Server           disabled
mysql57-community-source           MySQL 5.7 Community Server - Source  disabled
mysql80-community                  MySQL 8.0 Community Server           enabled
mysql80-community-source           MySQL 8.0 Community Server - Source  disabled
[root@iZ2zeh3bjq6rgnw0phucy7Z mysql]# yum repolist enabled | grep mysql
Invalid configuration value: failovermethod=priority in /etc/yum.repos.d/CentOS-epel.repo; Configuration: OptionBinding with id "failovermethod" does not exist
mysql-connectors-community    MySQL Connectors Community
mysql-tools-community         MySQL Tools Community
mysql80-community             MySQL 8.0 Community Server

安装mysql如果报一下错误就先执行下一步

[root@iZ2zeh3bjq6rgnw0phucy7Z mysql]# yum install mysql-community-server
Invalid configuration value: failovermethod=priority in /etc/yum.repos.d/CentOS-epel.repo; Configuration: OptionBinding with id "failovermethod" does not exist
MySQL 8.0 Community Server                                                                  1.0 MB/s | 2.1 MB     00:02    
Last metadata expiration check: 0:00:02 ago on Fri 17 Dec 2021 03:50:20 PM CST.
All matches were filtered out by modular filtering for argument: mysql-community-server
Error: Unable to find a match: mysql-community-server

yum module disable mysql

[root@iZ2zeh3bjq6rgnw0phucy7Z mysql]# yum module disable mysql
Invalid configuration value: failovermethod=priority in /etc/yum.repos.d/CentOS-epel.repo; Configuration: OptionBinding with id "failovermethod" does not exist
Last metadata expiration check: 0:03:27 ago on Fri 17 Dec 2021 03:50:20 PM CST.
Dependencies resolved.
============================================================================================================================
 Package                      Architecture                Version                        Repository                    Size
============================================================================================================================
Disabling modules:
 mysql                                                                                                                     

Transaction Summary
============================================================================================================================

Is this ok [y/N]: y
Complete!
[root@iZ2zeh3bjq6rgnw0phucy7Z mysql]# yum install mysql-community-server
Invalid configuration value: failovermethod=priority in /etc/yum.repos.d/CentOS-epel.repo; Configuration: OptionBinding with id "failovermethod" does not exist
Last metadata expiration check: 0:03:41 ago on Fri 17 Dec 2021 03:50:20 PM CST.
Dependencies resolved.
============================================================================================================================
 Package                                   Architecture      Version                     Repository                    Size
============================================================================================================================
Installing:
 mysql-community-server                    x86_64            8.0.27-1.el7                mysql80-community            448 M
Installing dependencies:
 compat-openssl10                          x86_64            1:1.0.2o-3.el8              appstream                    1.1 M
 mysql-community-client                    x86_64            8.0.27-1.el7                mysql80-community             53 M
 mysql-community-client-plugins            x86_64            8.0.27-1.el7                mysql80-community            5.7 M
 mysql-community-common                    x86_64            8.0.27-1.el7                mysql80-community            627 k
 mysql-community-libs                      x86_64            8.0.27-1.el7                mysql80-community            4.7 M

Transaction Summary
============================================================================================================================
Install  6 Packages

Total download size: 513 M
Installed size: 2.4 G
Is this ok [y/N]: y
Downloading Packages:
(1/6): compat-openssl10-1.0.2o-3.el8.x86_64.rpm                                             2.7 MB/s | 1.1 MB     00:00    
(2/6): mysql-community-common-8.0.27-1.el7.x86_64.rpm                                       455 kB/s | 627 kB     00:01    
(3/6): mysql-community-client-plugins-8.0.27-1.el7.x86_64.rpm                               2.5 MB/s | 5.7 MB     00:02    
(4/6): mysql-community-libs-8.0.27-1.el7.x86_64.rpm                                         4.3 MB/s | 4.7 MB     00:01    
(5/6): mysql-community-client-8.0.27-1.el7.x86_64.rpm                                       5.8 MB/s |  53 MB     00:09    
(6/6): mysql-community-server-8.0.27-1.el7.x86_64.rpm                                       9.9 MB/s | 448 MB     00:45    
----------------------------------------------------------------------------------------------------------------------------
Total                                                                                        11 MB/s | 513 MB     00:47     
MySQL 8.0 Community Server                                                                   27 MB/s |  27 kB     00:00    
Importing GPG key 0x5072E1F5:
 Userid     : "MySQL Release Engineering <mysql-build@oss.oracle.com>"
 Fingerprint: A4A9 4068 76FC BD3C 4567 70C8 8C71 8D3B 5072 E1F5
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Is this ok [y/N]: y
Key imported successfully
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                    1/1 
  Installing       : compat-openssl10-1:1.0.2o-3.el8.x86_64                                                             1/6 
  Running scriptlet: compat-openssl10-1:1.0.2o-3.el8.x86_64                                                             1/6 
  Installing       : mysql-community-client-plugins-8.0.27-1.el7.x86_64                                                 2/6 
  Installing       : mysql-community-common-8.0.27-1.el7.x86_64                                                         3/6 
  Installing       : mysql-community-libs-8.0.27-1.el7.x86_64                                                           4/6 
  Running scriptlet: mysql-community-libs-8.0.27-1.el7.x86_64                                                           4/6 
  Installing       : mysql-community-client-8.0.27-1.el7.x86_64                                                         5/6 
  Running scriptlet: mysql-community-server-8.0.27-1.el7.x86_64                                                                                                                                                                                                           6/6 
  Installing       : mysql-community-server-8.0.27-1.el7.x86_64                                                                                                                                                                                                           6/6 
  Running scriptlet: mysql-community-server-8.0.27-1.el7.x86_64                                                                                                                                                                                                           6/6 
[/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.

  Verifying        : compat-openssl10-1:1.0.2o-3.el8.x86_64                                                                                                                                                                                                               1/6 
  Verifying        : mysql-community-client-8.0.27-1.el7.x86_64                                                                                                                                                                                                           2/6 
  Verifying        : mysql-community-client-plugins-8.0.27-1.el7.x86_64                                                                                                                                                                                                   3/6 
  Verifying        : mysql-community-common-8.0.27-1.el7.x86_64                                                                                                                                                                                                           4/6 
  Verifying        : mysql-community-libs-8.0.27-1.el7.x86_64                                                                                                                                                                                                             5/6 
  Verifying        : mysql-community-server-8.0.27-1.el7.x86_64                                                                                                                                                                                                           6/6 

Installed:
  compat-openssl10-1:1.0.2o-3.el8.x86_64  mysql-community-client-8.0.27-1.el7.x86_64  mysql-community-client-plugins-8.0.27-1.el7.x86_64  mysql-community-common-8.0.27-1.el7.x86_64  mysql-community-libs-8.0.27-1.el7.x86_64  mysql-community-server-8.0.27-1.el7.x86_64 

Complete!

启动mysql

[root@iZ2zeh3bjq6rgnw0phucy7Z mysql]# service mysqld restart &

获取初始密码

[root@iZ2zeh3bjq6rgnw0phucy7Z mysql]# grep 'temporary password' /var/log/mysqld.log
2021-12-17T07:57:25.782780Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: aiMwo_)nu1v;

修改密码

alter user 'root'@'localhost' identified by 'Dfff9964.';

yum install mysql-community-server错误解决方案

centos7下 mysql5.7.9(8.0)启动失败问题

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值