CentOS7 官方yum源安装mysql8.0

 

[root@centos01 centos01]# yum list installed | grep mysql
akonadi-mysql.x86_64                   1.9.2-4.el7                     @anaconda
qt-mysql.x86_64                        1:4.8.7-2.el7                   @anaconda
[root@centos01 centos01]# 
[root@centos01 centos01]# rpm -aq |grep mysql
qt-mysql-4.8.7-2.el7.x86_64
akonadi-mysql-1.9.2-4.el7.x86_64
[root@centos01 centos01]# 
[root@centos01 centos01]# 
[root@centos01 centos01]# cd /usr/local/mysql
[root@centos01 mysql]# ll
总用量 0
[root@centos01 mysql]# wget https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm
--2018-08-15 00:19:03--  https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm
正在解析主机 dev.mysql.com (dev.mysql.com)... 137.254.60.11
正在连接 dev.mysql.com (dev.mysql.com)|137.254.60.11|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 302 Found
位置:https://repo.mysql.com//mysql80-community-release-el7-1.noarch.rpm [跟随至新的 URL]
--2018-08-15 00:19:05--  https://repo.mysql.com//mysql80-community-release-el7-1.noarch.rpm
正在解析主机 repo.mysql.com (repo.mysql.com)... 23.35.177.109
正在连接 repo.mysql.com (repo.mysql.com)|23.35.177.109|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:25820 (25K) [application/x-redhat-package-manager]
正在保存至: “mysql80-community-release-el7-1.noarch.rpm”

100%[====================================================================>] 25,820      --.-K/s 用时 0s      

2018-08-15 00:19:06 (342 MB/s) - 已保存 “mysql80-community-release-el7-1.noarch.rpm” [25820/25820])

[root@centos01 mysql]# 
[root@centos01 mysql]# ll
总用量 28
-rw-r--r--. 1 root root 25820 4月  18 13:24 mysql80-community-release-el7-1.noarch.rpm
[root@centos01 mysql]# 
[root@centos01 mysql]# rpm -qpl mysql80-community-release-el7-1.noarch.rpm
警告:mysql80-community-release-el7-1.noarch.rpm: 头V3 DSA/SHA1 Signature, 密钥 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@centos01 mysql]# 
[root@centos01 mysql]# rpm -ivh mysql80-community-release-el7-1.noarch.rpm
警告:mysql80-community-release-el7-1.noarch.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY
准备中...                          ################################# [100%]
正在升级/安装...
   1:mysql80-community-release-el7-1  ################################# [100%]
[root@centos01 mysql]# 
[root@centos01 mysql]# yum list installed | grep mysql
akonadi-mysql.x86_64                   1.9.2-4.el7                     @anaconda
mysql80-community-release.noarch       el7-1                           installed
qt-mysql.x86_64                        1:4.8.7-2.el7                   @anaconda
[root@centos01 mysql]# 
[root@centos01 mysql]# 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 - Sou 禁用
mysql-cluster-7.6-community/x86_64 MySQL Cluster 7.6 Community       禁用
mysql-cluster-7.6-community-source MySQL Cluster 7.6 Community - Sou 禁用
mysql-connectors-community/x86_64  MySQL Connectors Community        启用:    63
mysql-connectors-community-source  MySQL Connectors Community - Sour 禁用
mysql-tools-community/x86_64       MySQL Tools Community             启用:    69
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 - Sour 禁用
mysql56-community/x86_64           MySQL 5.6 Community Server        禁用
mysql56-community-source           MySQL 5.6 Community Server - Sour 禁用
mysql57-community/x86_64           MySQL 5.7 Community Server        禁用
mysql57-community-source           MySQL 5.7 Community Server - Sour 禁用
mysql80-community/x86_64           MySQL 8.0 Community Server        启用:    33
mysql80-community-source           MySQL 8.0 Community Server - Sour 禁用
[root@centos01 mysql]# 
[root@centos01 mysql]# yum repolist enabled | grep mysql
mysql-connectors-community/x86_64 MySQL Connectors Community                  63
mysql-tools-community/x86_64      MySQL Tools Community                       69
mysql80-community/x86_64          MySQL 8.0 Community Server                  33
[root@centos01 mysql]# 
[root@centos01 mysql]# yum install mysql-community-server
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
正在解决依赖关系
--> 正在检查事务
---> 软件包 mysql-community-server.x86_64.0.8.0.12-1.el7 将被 安装
--> 正在处理依赖关系 mysql-community-common(x86-64) = 8.0.12-1.el7,它被软件包 mysql-community-server-8.0.12-1.el7.x86_64 需要
--> 正在处理依赖关系 mysql-community-client(x86-64) >= 8.0.0,它被软件包 mysql-community-server-8.0.12-1.el7.x86_64 需要
--> 正在检查事务
---> 软件包 mysql-community-client.x86_64.0.8.0.12-1.el7 将被 安装
--> 正在处理依赖关系 mysql-community-libs(x86-64) >= 8.0.0,它被软件包 mysql-community-client-8.0.12-1.el7.x86_64 需要
---> 软件包 mysql-community-common.x86_64.0.8.0.12-1.el7 将被 安装
--> 正在检查事务
---> 软件包 mysql-community-libs.x86_64.0.8.0.12-1.el7 将被 安装
--> 解决依赖关系完成

依赖关系解决

==============================================================================================================
 Package                          架构             版本                     源                           大小
==============================================================================================================
正在安装:
 mysql-community-server           x86_64           8.0.12-1.el7             mysql80-community           349 M
为依赖而安装:
 mysql-community-client           x86_64           8.0.12-1.el7             mysql80-community            26 M
 mysql-community-common           x86_64           8.0.12-1.el7             mysql80-community           541 k
 mysql-community-libs             x86_64           8.0.12-1.el7             mysql80-community           2.2 M

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

总下载量:377 M
安装大小:1.7 G
Is this ok [y/d/N]: y
Downloading packages:
警告:/var/cache/yum/x86_64/7/mysql80-community/packages/mysql-community-common-8.0.12-1.el7.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY
mysql-community-common-8.0.12-1.el7.x86_64.rpm 的公钥尚未安装
(1/4): mysql-community-common-8.0.12-1.el7.x86_64.rpm                                  | 541 kB  00:00:05     
(2/4): mysql-community-client-8.0.12-1.el7.x86_64.rpm                                  |  26 MB  00:01:02     
(3/4): mysql-community-libs-8.0.12-1.el7.x86_64.rpm                                    | 2.2 MB  00:00:56     
(4/4): mysql-community-server-8.0.12-1.el7.x86_64.rpm                                  | 349 MB  00:12:35     
----------------------------------------------------------------------------------------------------------
总计                                                                           472 kB/s | 377 MB  00:13:38     
从 file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql 检索密钥
导入 GPG key 0x5072E1F5:
 用户ID     : "MySQL Release Engineering <mysql-build@oss.oracle.com>"
 指纹       : a4a9 4068 76fc bd3c 4567 70c8 8c71 8d3b 5072 e1f5
 软件包     : mysql80-community-release-el7-1.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 程序修改。
** 发现 191 个已存在的 RPM 数据库问题, 'yum check' 输出如下:
akonadi-mysql-1.9.2-4.el7.x86_64 有缺少的需求 mariadb-server
antlr-tool-2.7.7-30.el7.noarch 有缺少的需求 java >= ('1', '1.7.0', None)
antlr-tool-2.7.7-30.el7.noarch 有缺少的需求 jpackage-utils
antlr-tool-2.7.7-30.el7.noarch 有缺少的需求 jpackage-utils
apache-commons-cli-1.2-13.el7.noarch 有缺少的需求 java >= ('0', '1.5', None)
apache-commons-cli-1.2-13.el7.noarch 有缺少的需求 jpackage-utils
apache-commons-codec-1.8-7.el7.noarch 有缺少的需求 java >= ('1', '1.6', None)
apache-commons-codec-1.8-7.el7.noarch 有缺少的需求 jpackage-utils
apache-commons-collections-3.2.1-22.el7_2.noarch 有缺少的需求 java >= ('0', '1.5', None)
apache-commons-collections-3.2.1-22.el7_2.noarch 有缺少的需求 jpackage-utils
apache-commons-daemon-1.0.13-7.el7.x86_64 有缺少的需求 java >= ('0', '1.5', None)
apache-commons-daemon-1.0.13-7.el7.x86_64 有缺少的需求 jpackage-utils
apache-commons-dbcp-1.4-17.el7.noarch 有缺少的需求 java >= ('1', '1.6', None)
apache-commons-dbcp-1.4-17.el7.noarch 有缺少的需求 jpackage-utils
apache-commons-lang-2.6-15.el7.noarch 有缺少的需求 java >= ('0', '1.3', None)
apache-commons-lang-2.6-15.el7.noarch 有缺少的需求 jpackage-utils
apache-commons-logging-1.1.2-7.el7.noarch 有缺少的需求 java >= ('0', '1.5', None)
apache-commons-logging-1.1.2-7.el7.noarch 有缺少的需求 jpackage-utils
apache-commons-pool-1.6-9.el7.noarch 有缺少的需求 java >= ('0', '1.5', None)
apache-commons-pool-1.6-9.el7.noarch 有缺少的需求 jpackage-utils
.....
.....
.....
.....
..... xml
-commons-apis-1.4.01-16.el7.noarch 有缺少的需求 java xml-commons-apis-1.4.01-16.el7.noarch 有缺少的需求 jpackage-utils xml-commons-apis-1.4.01-16.el7.noarch 有缺少的需求 jpackage-utils xml-commons-resolver-1.2-15.el7.noarch 有缺少的需求 jpackage-utils xml-commons-resolver-1.2-15.el7.noarch 有缺少的需求 jpackage-utils xpp3-1.1.3.8-11.el7.noarch 有缺少的需求 java xpp3-1.1.3.8-11.el7.noarch 有缺少的需求 jpackage-utils xsom-0-10.20110809svn.el7.noarch 有缺少的需求 jpackage-utils xsom-0-10.20110809svn.el7.noarch 有缺少的需求 jpackage-utils 正在安装 : mysql-community-common-8.0.12-1.el7.x86_64 1/4 正在安装 : mysql-community-libs-8.0.12-1.el7.x86_64 2/4 正在安装 : mysql-community-client-8.0.12-1.el7.x86_64 3/4 正在安装 : mysql-community-server-8.0.12-1.el7.x86_64 4/4 验证中 : mysql-community-common-8.0.12-1.el7.x86_64 1/4 验证中 : mysql-community-libs-8.0.12-1.el7.x86_64 2/4 验证中 : mysql-community-client-8.0.12-1.el7.x86_64 3/4 验证中 : mysql-community-server-8.0.12-1.el7.x86_64 4/4 已安装: mysql-community-server.x86_64 0:8.0.12-1.el7 作为依赖被安装: mysql-community-client.x86_64 0:8.0.12-1.el7 mysql-community-common.x86_64 0:8.0.12-1.el7 mysql-community-libs.x86_64 0:8.0.12-1.el7 完毕! [root@centos01 mysql]# [root@centos01 mysql]#

 

[root@centos01 mysql]# 
[root@centos01 mysql]# mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
[root@centos01 mysql]# 
[root@centos01 mysql]# service mysql start
Redirecting to /bin/systemctl start mysql.service
Failed to start mysql.service: Unit not found.
[root@centos01 mysql]# service mysqlid status
Redirecting to /bin/systemctl status mysqlid.service
Unit mysqlid.service could not be found.
[root@centos01 mysql]# mysql -version
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
[root@centos01 mysql]# 

 

[centos01@centos01 ~]$ mysql
ERROR 1045 (28000): Access denied for user 'centos01'@'localhost' (using password: NO)
[centos01@centos01 ~]$ service mysqld restart
Redirecting to /bin/systemctl restart mysqld.service
[centos01@centos01 ~]$ 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 四 2018-08-16 01:14:36 CST; 42s ago
     Docs: man:mysqld(8)
           http://dev.mysql.com/doc/refman/en/using-systemd.html
  Process: 3481 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
 Main PID: 3503 (mysqld)
   Status: "SERVER_OPERATING"
    Tasks: 37
   CGroup: /system.slice/mysqld.service
           └─3503 /usr/sbin/mysqld

8月 16 01:14:27 centos01 systemd[1]: Starting MySQL Server...
8月 16 01:14:36 centos01 systemd[1]: Started MySQL Server.
[centos01@centos01 ~]$ 
[centos01@centos01 ~]$ 

 

 

 查看安装后的随机密码

[root@centos01 mysql]# grep 'temporary password' /var/log/mysqld.log
2018-08-15T17:04:38.092581Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: tSf8LT<_.7Z5

 

 用mysql生成的随机登录mysql,然后修改密码。

[root@centos01 /]# service mysqld start
Redirecting to /bin/systemctl start mysqld.service
[root@centos01 /]# 
[root@centos01 /]# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.12

Copyright (c) 2000, 2018, 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>
mysql> select version();
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql> alter user 'root'@'localhost' identified by 'sa1234';
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
mysql> alter user 'root'@'localhost' identified by 'sa1234admin';
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
mysql>
mysql> alter user 'root'@'localhost' identified by 'sa123_ADMIN.';
Query OK, 0 rows affected (0.36 sec)

mysql> select version();
+-----------+
| version() |
+-----------+
| 8.0.12    |
+-----------+
1 row in set (0.00 sec)

mysql> status
--------------
mysql  Ver 8.0.12 for Linux on x86_64 (MySQL Community Server - GPL)

Connection id:          9
Current database:    
Current user:           root@localhost
SSL:                    Not in use
Current pager:          stdout
Using outfile:          ''
Using delimiter:        ;
Server version:         8.0.12
Protocol version:       10
Connection:             Localhost via UNIX socket
Server characterset:    utf8mb4
Db     characterset:    utf8mb4
Client characterset:    utf8mb4
Conn.  characterset:    utf8mb4
UNIX socket:            /var/lib/mysql/mysql.sock
Uptime:                 45 min 34 sec

Threads: 2  Questions: 14  Slow queries: 0  Opens: 120  Flush tables: 2  Open tables: 96  Queries per second avg: 0.005
--------------

mysql> 

 

数据库操作

mysql> create database testdb;
Query OK, 1 row affected (0.21 sec)

mysql> 
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
| testdb             |
+--------------------+
5 rows in set (0.01 sec)

mysql> 
mysql> use testdb;
Database changed
mysql> 

 

posted @ 2018-08-15 22:41  茗::流  阅读(5231)  评论(0编辑  收藏  举报
如有雷同,纯属参考。如有侵犯你的版权,请联系我。