Centos7-minimal 安装Mysql8.0及密码修改 全过程示例

[root@localhost download]# wget http://repo.mysql.com/mysql80-community-release-el7-2.noarch.rpm
--2019-03-12 14:49:38--  http://repo.mysql.com/mysql80-community-release-el7-2.noarch.rpm
正在解析主机 repo.mysql.com (repo.mysql.com)... 104.95.206.140
正在连接 repo.mysql.com (repo.mysql.com)|104.95.206.140|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 302 Found
位置:http://59.80.44.99/repo.mysql.com/mysql80-community-release-el7-2.noarch.rpm [跟随至新的 URL]
--2019-03-12 14:49:42--  http://59.80.44.99/repo.mysql.com/mysql80-community-release-el7-2.noarch.rpm
正在连接 59.80.44.99:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:25892 (25K) [application/x-redhat-package-manager]
正在保存至: “mysql80-community-release-el7-2.noarch.rpm”

100%[=============================================================>] 25,892       145KB/s 用时 0.2s   

2019-03-12 14:49:42 (145 KB/s) - 已保存 “mysql80-community-release-el7-2.noarch.rpm” [25892/25892])

[root@localhost download]# rpm -ivh mysql80-community-release-el7-2.noarch.rpm 
警告:mysql80-community-release-el7-2.noarch.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY
准备中...                          ################################# [100%]
正在升级/安装...
   1:mysql80-community-release-el7-2  ################################# [100%]
[root@localhost download]# yum repolist all | grep mysql
mysql-cluster-7.5-community/x86_64 MySQL Cluster 7.5 Community      禁用
mysql-cluster-7.5-community-source MySQL Cluster 7.5 Community - So 禁用
mysql-cluster-7.6-community/x86_64 MySQL Cluster 7.6 Community      禁用
mysql-cluster-7.6-community-source MySQL Cluster 7.6 Community - So 禁用
mysql-connectors-community/x86_64  MySQL Connectors Community       启用:     95
mysql-connectors-community-source  MySQL Connectors Community - Sou 禁用
mysql-tools-community/x86_64       MySQL Tools Community            启用:     84
mysql-tools-community-source       MySQL Tools Community - Source   禁用
mysql-tools-preview/x86_64         MySQL Tools Preview              禁用
mysql-tools-preview-source         MySQL Tools Preview - Source     禁用
mysql55-community/x86_64           MySQL 5.5 Community Server       禁用
mysql55-community-source           MySQL 5.5 Community Server - Sou 禁用
mysql56-community/x86_64           MySQL 5.6 Community Server       禁用
mysql56-community-source           MySQL 5.6 Community Server - Sou 禁用
mysql57-community/x86_64           MySQL 5.7 Community Server       禁用
mysql57-community-source           MySQL 5.7 Community Server - Sou 禁用
mysql80-community/x86_64           MySQL 8.0 Community Server       启用:     82
mysql80-community-source           MySQL 8.0 Community Server - Sou 禁用
[root@localhost download]# yum install mysql-community-server
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.163.com
 * extras: mirrors.163.com
 * updates: mirrors.huaweicloud.com
base                                                                            | 3.6 kB  00:00:00     
extras                                                                          | 3.4 kB  00:00:00     
updates                                                                         | 3.4 kB  00:00:00     
正在解决依赖关系
--> 正在检查事务
---> 软件包 mysql-community-server.x86_64.0.8.0.15-1.el7 将被 安装
--> 正在处理依赖关系 mysql-community-common(x86-64) = 8.0.15-1.el7,它被软件包 mysql-community-server-8.0.15-1.el7.x86_64 需要
--> 正在处理依赖关系 mysql-community-client(x86-64) >= 8.0.0,它被软件包 mysql-community-server-8.0.15-1.el7.x86_64 需要
--> 正在检查事务
---> 软件包 mysql-community-client.x86_64.0.8.0.15-1.el7 将被 安装
--> 正在处理依赖关系 mysql-community-libs(x86-64) >= 8.0.0,它被软件包 mysql-community-client-8.0.15-1.el7.x86_64 需要
---> 软件包 mysql-community-common.x86_64.0.8.0.15-1.el7 将被 安装
--> 正在检查事务
---> 软件包 mariadb-libs.x86_64.1.5.5.60-1.el7_5 将被 取代
--> 正在处理依赖关系 libmysqlclient.so.18()(64bit),它被软件包 2:postfix-2.10.1-7.el7.x86_64 需要
--> 正在处理依赖关系 libmysqlclient.so.18(libmysqlclient_18)(64bit),它被软件包 2:postfix-2.10.1-7.el7.x86_64 需要
---> 软件包 mysql-community-libs.x86_64.0.8.0.15-1.el7 将被 舍弃
--> 正在检查事务
---> 软件包 mysql-community-libs-compat.x86_64.0.8.0.15-1.el7 将被 舍弃
--> 解决依赖关系完成

依赖关系解决

=======================================================================================================
 Package                            架构          版本                  源                        大小
=======================================================================================================
正在安装:
 mysql-community-libs               x86_64        8.0.15-1.el7          mysql80-community        2.2 M
      替换  mariadb-libs.x86_64 1:5.5.60-1.el7_5
 mysql-community-libs-compat        x86_64        8.0.15-1.el7          mysql80-community        2.1 M
      替换  mariadb-libs.x86_64 1:5.5.60-1.el7_5
 mysql-community-server             x86_64        8.0.15-1.el7          mysql80-community        360 M
为依赖而安装:
 mysql-community-client             x86_64        8.0.15-1.el7          mysql80-community         25 M
 mysql-community-common             x86_64        8.0.15-1.el7          mysql80-community        566 k

事务概要
=======================================================================================================
安装  3 软件包 (+2 依赖软件包)

总下载量:391 M
Is this ok [y/d/N]: y
Downloading packages:
警告:/var/cache/yum/x86_64/7/mysql80-community/packages/mysql-community-common-8.0.15-1.el7.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY
mysql-community-common-8.0.15-1.el7.x86_64.rpm 的公钥尚未安装
(1/5): mysql-community-common-8.0.15-1.el7.x86_64.rpm                           | 566 kB  00:00:09     
(2/5): mysql-community-libs-8.0.15-1.el7.x86_64.rpm                             | 2.2 MB  00:00:17     
(3/5): mysql-community-libs-compat-8.0.15-1.el7.x86_64.rpm                      | 2.1 MB  00:00:22     
(4/5): mysql-community-client-8.0.15-1.el7.x86_64.rpm                           |  25 MB  00:03:47     
(5/5): mysql-community-server-8.0.15-1.el7.x86_64.rpm                           | 360 MB  00:28:00     
-------------------------------------------------------------------------------------------------------
总计                                                                   231 kB/s | 391 MB  00:28:50     
从 file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql 检索密钥
导入 GPG key 0x5072E1F5:
 用户ID     : "MySQL Release Engineering <[email protected]>"
 指纹       : a4a9 4068 76fc bd3c 4567 70c8 8c71 8d3b 5072 e1f5
 软件包     : mysql80-community-release-el7-2.noarch (installed)
 来自       : /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
是否继续?[y/N]:y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
警告:RPM 数据库已被非 yum 程序修改。
  正在安装    : mysql-community-common-8.0.15-1.el7.x86_64                                         1/6 
  正在安装    : mysql-community-libs-8.0.15-1.el7.x86_64                                           2/6 
  正在安装    : mysql-community-client-8.0.15-1.el7.x86_64                                         3/6 
  正在安装    : mysql-community-server-8.0.15-1.el7.x86_64                                         4/6 
  正在安装    : mysql-community-libs-compat-8.0.15-1.el7.x86_64                                    5/6 
  正在删除    : 1:mariadb-libs-5.5.60-1.el7_5.x86_64                                               6/6 
  验证中      : mysql-community-libs-compat-8.0.15-1.el7.x86_64                                    1/6 
  验证中      : mysql-community-common-8.0.15-1.el7.x86_64                                         2/6 
  验证中      : mysql-community-server-8.0.15-1.el7.x86_64                                         3/6 
  验证中      : mysql-community-client-8.0.15-1.el7.x86_64                                         4/6 
  验证中      : mysql-community-libs-8.0.15-1.el7.x86_64                                           5/6 
  验证中      : 1:mariadb-libs-5.5.60-1.el7_5.x86_64                                               6/6 

已安装:
  mysql-community-libs.x86_64 0:8.0.15-1.el7      mysql-community-libs-compat.x86_64 0:8.0.15-1.el7   
  mysql-community-server.x86_64 0:8.0.15-1.el7   

作为依赖被安装:
  mysql-community-client.x86_64 0:8.0.15-1.el7       mysql-community-common.x86_64 0:8.0.15-1.el7      

替代:
  mariadb-libs.x86_64 1:5.5.60-1.el7_5                                                                 

完毕!
[root@localhost download]# sudo service mysqld start
Redirecting to /bin/systemctl start mysqld.service
[root@localhost download]# sudo service mysqld status
Redirecting to /bin/systemctl status mysqld.service
mysqld.service - MySQL Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: active (running) since 二 2019-03-12 15:31:13 CST; 13s ago
     Docs: man:mysqld(8)
           http://dev.mysql.com/doc/refman/en/using-systemd.html
  Process: 5563 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
 Main PID: 5631 (mysqld)
   Status: "SERVER_OPERATING"
   CGroup: /system.slice/mysqld.service
           └─5631 /usr/sbin/mysqld

3月 12 15:30:19 localhost.localdomain systemd[1]: Starting MySQL Server...
3月 12 15:31:13 localhost.localdomain systemd[1]: Started MySQL Server.
[root@localhost download]# sudo grep 'temporary password' /var/log/mysqld.log
2019-03-12T07:30:51.824375Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: xs/<YQyaF0sp
[root@localhost download]# 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.15

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

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 'Qwe123!@#';//注意密码复杂度,大小写字母、数字与符号组合
Query OK, 0 rows affected (0.15 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.10 sec)

mysql> quit
Bye

猜你喜欢

转载自blog.csdn.net/IAGod/article/details/88422603
今日推荐