centos7 安装mysql 5.7

 

 

CentOS 7的yum源中貌似没有正常安装MySQL时的mysql-sever文件。需要去官网下载

1、配置YUM源

去 MySQL官网下载MySQL的rpm安装包,点击下载地址:下载地址

如果是直接在Linux中下载,则使用:

 

[plain] view plain copy
 
 在CODE上查看代码片派生到我的代码片
  1. # wget  http://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm  

如果是在windows下下载,使用winSCP或者其他工具将其移动到Linux中即可。

2、本地安装YUM源

[plain] view plain copy
 
 在CODE上查看代码片派生到我的代码片
  1. # yum install mysql57-community-release-el7-8.noarch.rpm  

3、安装MySQL

# yum install mysql-community-server

4、启动MySQL并加入开机启动

[plain] view plain copy
 
 在CODE上查看代码片派生到我的代码片
  1. # systemctl start mysqld  
  2. # systemctl enable mysqld   
  3. # systemctl daemon-reload  

5、修改root密码

MySQL安装完成之后,在/var/log/mysqld.log文件中为root用户生成了一个随机的默认密码。可以通过以下方式查看,之后可登陆MySQL进行修改:

#grep 'temporary password' /var/log/mysqld.log

这里需要注意:MySQL5.7默认的密码检查策略要求密码必须包含:大小写字母、数字和特殊符号,并且长度不能少于8位。否则会提示ERROR 1819 (HY000): Your password does not satisfy the current policy requirements错误。

通过msyql环境变量可以查看密码策略的相关信息:

[plain] view plain copy
 
 在CODE上查看代码片派生到我的代码片
  1. mysql> show variables like '%password%';  

说明:

validate_password_dictionary_file:密码策略文件,策略为STRONG才需要 

validate_password_length:密码最少长度 

validate_password_mixed_case_count:大小写字符长度,至少1个 

validate_password_number_count :数字至少1个 

validate_password_special_char_count:特殊字符至少1个 上述参数是默认策略MEDIUM的密码检查规则。

validate_password_policy:密码策略,默认为MEDIUM策略 ,共有如下三种密码策略:

 

策略检查规则
0 or LOW Length
1 or MEDIUM Length; numeric, lowercase/uppercase, and special characters
2 or STRONG Length; numeric, lowercase/uppercase, and special characters; dictionary file

 

 

当然我们也可以通过修改/etc/my.cnf文件,通过添加validate_password_policy配置,来指定密码策略,如下:


validate_password_policy=0 #0(LOW),1(MEDIUM),2(STRONG)其中一种,注意2需要提供密码字典文件

 

如果不需要密码策略,添加my.cnf文件中添加如下配置禁用即可:

 

[plain] view plain copy
 
 在CODE上查看代码片派生到我的代码片
  1. validate_password = off  

修改完后记得需要重新启动MySQL服务

6、添加远程登陆用户

      在我们使用mysql数据库时,有时我们的程序与数据库不在同一机器上,这时我们需要远程访问数据库。缺省状态下,mysql的用户没有远程访问的权限。

      以下语句赋予root用户从任意主机访问MySQL服务器:

[plain] view plain copy
 
 在CODE上查看代码片派生到我的代码片
  1. mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'WITH GRANT OPTION  

 以下语句赋予user用户使用password密码从任何主机访问MySQL服务器:

[plain] view plain copy
 
 在CODE上查看代码片派生到我的代码片
  1. mysql>GRANT ALL PRIVILEGES ON *.* TO 'user'@'%'IDENTIFIED BY 'password' WITH GRANT OPTION;  
  2. mysql>FLUSH PRIVILEGES  #使修改生效  

 

注意:

a、如果没有开启防火墙,则不需要配置开放3306端口,如果打开了firewall或者iptables防火墙,则需要在防火墙里打开3306防火墙,例如对于iptables的防火墙:

[plain] view plain copy
 
 在CODE上查看代码片派生到我的代码片
  1. #sudo vim /etc/sysconfig/iptables  

并在该文件内添加如下配置:

[plain] view plain copy
 
 在CODE上查看代码片派生到我的代码片
  1. -A INPUT -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCEPT  

退出并保存后重启防火墙:

[plain] view plain copy
 
 在CODE上查看代码片派生到我的代码片
  1. #sudo service iptables restart  

b、如果该MySQL是部署在腾讯云/阿里云上的,则需要按照他们的规则打开对外暴露的端口,例如腾讯云,默认只开启了22,内网所有端口全通,所以外网访问3306端口时需要通过腾讯安全组开通,而且默认linux操作系统没有安装防火墙。所以需要通过添加安全组来打开3306。

 

至此,CentOS7上安装MySQL完成

实录:

[root@Service-1 ~]# wget http://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm
--2016-11-18 05:06:38--  http://dev.mysql.com/get/mysql57-community-release-el7-9.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|:80... connected.
HTTP request sent, awaiting response... 302 Found
Location: http://repo.mysql.com//mysql57-community-release-el7-9.noarch.rpm [following]
--2016-11-18 05:06:38--  http://repo.mysql.com//mysql57-community-release-el7-9.noarch.rpm
Resolving repo.mysql.com (repo.mysql.com)... 184.31.154.72
Connecting to repo.mysql.com (repo.mysql.com)|184.31.154.72|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 9224 (9.0K) [application/x-redhat-package-manager]
Saving to: 鈥榤ysql57-community-release-el7-9.noarch.rpm鈥

100%[==================================================================================================================================================================>] 9,224       --.-K/s   in 0s      

2016-11-18 05:06:39 (26.2 MB/s) - 鈥榤ysql57-community-release-el7-9.noarch.rpm鈥saved [9224/9224]

[root@Service-1 ~]# ls
anaconda-ks.cfg                                 mysql-community-devel-5.7.16-1.el7.x86_64.rpm            mysql-community-libs-compat-5.7.16-1.el7.x86_64.rpm
mysql-5.7.16-1.el7.x86_64.rpm-bundle.tar        mysql-community-embedded-5.7.16-1.el7.x86_64.rpm         mysql-community-minimal-debuginfo-5.7.16-1.el7.x86_64.rpm
mysql57-community-release-el7-9.noarch.rpm      mysql-community-embedded-compat-5.7.16-1.el7.x86_64.rpm  mysql-community-server-5.7.16-1.el7.x86_64.rpm
mysql-community-client-5.7.16-1.el7.x86_64.rpm  mysql-community-embedded-devel-5.7.16-1.el7.x86_64.rpm   mysql-community-server-minimal-5.7.16-1.el7.x86_64.rpm
mysql-community-common-5.7.16-1.el7.x86_64.rpm  mysql-community-libs-5.7.16-1.el7.x86_64.rpm             mysql-community-test-5.7.16-1.el7.x86_64.rpm
[root@Service-1 ~]# rpm -ivh mysql57-community-release-el7-9.noarch.rpm 
warning: mysql57-community-release-el7-9.noarch.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:mysql57-community-release-el7-9  ################################# [100%]
[root@Service-1 ~]# yum install mysql-community-server
Loaded plugins: fastestmirror
mysql-connectors-community                                                                                                                                                           | 2.5 kB  00:00:00     
mysql-tools-community                                                                                                                                                                | 2.5 kB  00:00:00     
mysql57-community                                                                                                                                                                    | 2.5 kB  00:00:00     
(1/3): mysql-tools-community/x86_64/primary_db                                                                                                                                       |  29 kB  00:00:01     
(2/3): mysql57-community/x86_64/primary_db                                                                                                                                           |  86 kB  00:00:03     
(3/3): mysql-connectors-community/x86_64/primary_db                                                                                                                                  |  11 kB  00:00:10     
Loading mirror speeds from cached hostfile
 * base: mirrors.btte.net
 * extras: mirrors.btte.net
 * updates: mirrors.btte.net
Resolving Dependencies
--> Running transaction check
---> Package mysql-community-server.x86_64 0:5.7.16-1.el7 will be installed
--> Processing Dependency: mysql-community-common(x86-64) = 5.7.16-1.el7 for package: mysql-community-server-5.7.16-1.el7.x86_64
--> Processing Dependency: mysql-community-client(x86-64) >= 5.7.9 for package: mysql-community-server-5.7.16-1.el7.x86_64
--> Processing Dependency: perl(strict) for package: mysql-community-server-5.7.16-1.el7.x86_64
--> Processing Dependency: perl(Getopt::Long) for package: mysql-community-server-5.7.16-1.el7.x86_64
--> Processing Dependency: /usr/bin/perl for package: mysql-community-server-5.7.16-1.el7.x86_64
--> Running transaction check
---> Package mysql-community-client.x86_64 0:5.7.16-1.el7 will be installed
--> Processing Dependency: mysql-community-libs(x86-64) >= 5.7.9 for package: mysql-community-client-5.7.16-1.el7.x86_64
---> Package mysql-community-common.x86_64 0:5.7.16-1.el7 will be installed
---> Package perl.x86_64 4:5.16.3-286.el7 will be installed
--> Processing Dependency: perl-libs = 4:5.16.3-286.el7 for package: 4:perl-5.16.3-286.el7.x86_64
--> Processing Dependency: perl(Socket) >= 1.3 for package: 4:perl-5.16.3-286.el7.x86_64
--> Processing Dependency: perl(Scalar::Util) >= 1.10 for package: 4:perl-5.16.3-286.el7.x86_64
--> Processing Dependency: perl-macros for package: 4:perl-5.16.3-286.el7.x86_64
--> Processing Dependency: perl-libs for package: 4:perl-5.16.3-286.el7.x86_64
--> Processing Dependency: perl(threads::shared) for package: 4:perl-5.16.3-286.el7.x86_64
--> Processing Dependency: perl(threads) for package: 4:perl-5.16.3-286.el7.x86_64
--> Processing Dependency: perl(constant) for package: 4:perl-5.16.3-286.el7.x86_64
--> Processing Dependency: perl(Time::Local) for package: 4:perl-5.16.3-286.el7.x86_64
--> Processing Dependency: perl(Time::HiRes) for package: 4:perl-5.16.3-286.el7.x86_64
--> Processing Dependency: perl(Storable) for package: 4:perl-5.16.3-286.el7.x86_64
--> Processing Dependency: perl(Socket) for package: 4:perl-5.16.3-286.el7.x86_64
--> Processing Dependency: perl(Scalar::Util) for package: 4:perl-5.16.3-286.el7.x86_64
--> Processing Dependency: perl(Pod::Simple::XHTML) for package: 4:perl-5.16.3-286.el7.x86_64
--> Processing Dependency: perl(Pod::Simple::Search) for package: 4:perl-5.16.3-286.el7.x86_64
--> Processing Dependency: perl(Filter::Util::Call) for package: 4:perl-5.16.3-286.el7.x86_64
--> Processing Dependency: perl(File::Temp) for package: 4:perl-5.16.3-286.el7.x86_64
--> Processing Dependency: perl(File::Spec::Unix) for package: 4:perl-5.16.3-286.el7.x86_64
--> Processing Dependency: perl(File::Spec::Functions) for package: 4:perl-5.16.3-286.el7.x86_64
--> Processing Dependency: perl(File::Spec) for package: 4:perl-5.16.3-286.el7.x86_64
--> Processing Dependency: perl(File::Path) for package: 4:perl-5.16.3-286.el7.x86_64
--> Processing Dependency: perl(Exporter) for package: 4:perl-5.16.3-286.el7.x86_64
--> Processing Dependency: perl(Cwd) for package: 4:perl-5.16.3-286.el7.x86_64
--> Processing Dependency: perl(Carp) for package: 4:perl-5.16.3-286.el7.x86_64
--> Processing Dependency: libperl.so()(64bit) for package: 4:perl-5.16.3-286.el7.x86_64
---> Package perl-Getopt-Long.noarch 0:2.40-2.el7 will be installed
--> Processing Dependency: perl(Pod::Usage) >= 1.14 for package: perl-Getopt-Long-2.40-2.el7.noarch
--> Processing Dependency: perl(Text::ParseWords) for package: perl-Getopt-Long-2.40-2.el7.noarch
--> Running transaction check
---> Package mariadb-libs.x86_64 1:5.5.50-1.el7_2 will be obsoleted
--> Processing Dependency: libmysqlclient.so.18()(64bit) for package: 2:postfix-2.10.1-6.el7.x86_64
--> Processing Dependency: libmysqlclient.so.18(libmysqlclient_18)(64bit) for package: 2:postfix-2.10.1-6.el7.x86_64
---> Package mysql-community-libs.x86_64 0:5.7.16-1.el7 will be obsoleting
---> Package perl-Carp.noarch 0:1.26-244.el7 will be installed
---> Package perl-Exporter.noarch 0:5.68-3.el7 will be installed
---> Package perl-File-Path.noarch 0:2.09-2.el7 will be installed
---> Package perl-File-Temp.noarch 0:0.23.01-3.el7 will be installed
---> Package perl-Filter.x86_64 0:1.49-3.el7 will be installed
---> Package perl-PathTools.x86_64 0:3.40-5.el7 will be installed
---> Package perl-Pod-Simple.noarch 1:3.28-4.el7 will be installed
--> Processing Dependency: perl(Pod::Escapes) >= 1.04 for package: 1:perl-Pod-Simple-3.28-4.el7.noarch
--> Processing Dependency: perl(Encode) for package: 1:perl-Pod-Simple-3.28-4.el7.noarch
---> Package perl-Pod-Usage.noarch 0:1.63-3.el7 will be installed
--> Processing Dependency: perl(Pod::Text) >= 3.15 for package: perl-Pod-Usage-1.63-3.el7.noarch
--> Processing Dependency: perl-Pod-Perldoc for package: perl-Pod-Usage-1.63-3.el7.noarch
---> Package perl-Scalar-List-Utils.x86_64 0:1.27-248.el7 will be installed
---> Package perl-Socket.x86_64 0:2.010-3.el7 will be installed
---> Package perl-Storable.x86_64 0:2.45-3.el7 will be installed
---> Package perl-Text-ParseWords.noarch 0:3.29-4.el7 will be installed
---> Package perl-Time-HiRes.x86_64 4:1.9725-3.el7 will be installed
---> Package perl-Time-Local.noarch 0:1.2300-2.el7 will be installed
---> Package perl-constant.noarch 0:1.27-2.el7 will be installed
---> Package perl-libs.x86_64 4:5.16.3-286.el7 will be installed
---> Package perl-macros.x86_64 4:5.16.3-286.el7 will be installed
---> Package perl-threads.x86_64 0:1.87-4.el7 will be installed
---> Package perl-threads-shared.x86_64 0:1.43-6.el7 will be installed
--> Running transaction check
---> Package mysql-community-libs-compat.x86_64 0:5.7.16-1.el7 will be obsoleting
---> Package perl-Encode.x86_64 0:2.51-7.el7 will be installed
---> Package perl-Pod-Escapes.noarch 1:1.04-286.el7 will be installed
---> Package perl-Pod-Perldoc.noarch 0:3.20-4.el7 will be installed
--> Processing Dependency: perl(parent) for package: perl-Pod-Perldoc-3.20-4.el7.noarch
--> Processing Dependency: perl(HTTP::Tiny) for package: perl-Pod-Perldoc-3.20-4.el7.noarch
---> Package perl-podlators.noarch 0:2.5.1-3.el7 will be installed
--> Running transaction check
---> Package perl-HTTP-Tiny.noarch 0:0.033-3.el7 will be installed
---> Package perl-parent.noarch 1:0.225-244.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

============================================================================================================================================================================================================
 Package                                                    Arch                                  Version                                            Repository                                        Size
============================================================================================================================================================================================================
Installing:
 mysql-community-libs                                       x86_64                                5.7.16-1.el7                                       mysql57-community                                2.1 M
     replacing  mariadb-libs.x86_64 1:5.5.50-1.el7_2
 mysql-community-libs-compat                                x86_64                                5.7.16-1.el7                                       mysql57-community                                2.0 M
     replacing  mariadb-libs.x86_64 1:5.5.50-1.el7_2
 mysql-community-server                                     x86_64                                5.7.16-1.el7                                       mysql57-community                                152 M
Installing for dependencies:
 mysql-community-client                                     x86_64                                5.7.16-1.el7                                       mysql57-community                                 24 M
 mysql-community-common                                     x86_64                                5.7.16-1.el7                                       mysql57-community                                271 k
 perl                                                       x86_64                                4:5.16.3-286.el7                                   base                                             8.0 M
 perl-Carp                                                  noarch                                1.26-244.el7                                       base                                              19 k
 perl-Encode                                                x86_64                                2.51-7.el7                                         base                                             1.5 M
 perl-Exporter                                              noarch                                5.68-3.el7                                         base                                              28 k
 perl-File-Path                                             noarch                                2.09-2.el7                                         base                                              26 k
 perl-File-Temp                                             noarch                                0.23.01-3.el7                                      base                                              56 k
 perl-Filter                                                x86_64                                1.49-3.el7                                         base                                              76 k
 perl-Getopt-Long                                           noarch                                2.40-2.el7                                         base                                              56 k
 perl-HTTP-Tiny                                             noarch                                0.033-3.el7                                        base                                              38 k
 perl-PathTools                                             x86_64                                3.40-5.el7                                         base                                              82 k
 perl-Pod-Escapes                                           noarch                                1:1.04-286.el7                                     base                                              50 k
 perl-Pod-Perldoc                                           noarch                                3.20-4.el7                                         base                                              87 k
 perl-Pod-Simple                                            noarch                                1:3.28-4.el7                                       base                                             216 k
 perl-Pod-Usage                                             noarch                                1.63-3.el7                                         base                                              27 k
 perl-Scalar-List-Utils                                     x86_64                                1.27-248.el7                                       base                                              36 k
 perl-Socket                                                x86_64                                2.010-3.el7                                        base                                              49 k
 perl-Storable                                              x86_64                                2.45-3.el7                                         base                                              77 k
 perl-Text-ParseWords                                       noarch                                3.29-4.el7                                         base                                              14 k
 perl-Time-HiRes                                            x86_64                                4:1.9725-3.el7                                     base                                              45 k
 perl-Time-Local                                            noarch                                1.2300-2.el7                                       base                                              24 k
 perl-constant                                              noarch                                1.27-2.el7                                         base                                              19 k
 perl-libs                                                  x86_64                                4:5.16.3-286.el7                                   base                                             687 k
 perl-macros                                                x86_64                                4:5.16.3-286.el7                                   base                                              43 k
 perl-parent                                                noarch                                1:0.225-244.el7                                    base                                              12 k
 perl-podlators                                             noarch                                2.5.1-3.el7                                        base                                             112 k
 perl-threads                                               x86_64                                1.87-4.el7                                         base                                              49 k
 perl-threads-shared                                        x86_64                                1.43-6.el7                                         base                                              39 k

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

Total download size: 192 M
Is this ok [y/d/N]: y
Downloading packages:
warning: /var/cache/yum/x86_64/7/mysql57-community/packages/mysql-community-common-5.7.16-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY          ] 277 kB/s | 268 kB  00:11:47 ETA 
Public key for mysql-community-common-5.7.16-1.el7.x86_64.rpm is not installed
(1/32): mysql-community-common-5.7.16-1.el7.x86_64.rpm                                                                                                                               | 271 kB  00:00:01     
(2/32): mysql-community-libs-5.7.16-1.el7.x86_64.rpm                                                                                                                                 | 2.1 MB  00:00:08     
(3/32): mysql-community-libs-compat-5.7.16-1.el7.x86_64.rpm                                                                                                                          | 2.0 MB  00:00:09     
(4/32): perl-Carp-1.26-244.el7.noarch.rpm                                                                                                                                            |  19 kB  00:00:00     
(5/32): perl-Exporter-5.68-3.el7.noarch.rpm                                                                                                                                          |  28 kB  00:00:00     
(6/32): perl-File-Path-2.09-2.el7.noarch.rpm                                                                                                                                         |  26 kB  00:00:00     
(7/32): perl-File-Temp-0.23.01-3.el7.noarch.rpm                                                                                                                                      |  56 kB  00:00:00     
(8/32): perl-Filter-1.49-3.el7.x86_64.rpm                                                                                                                                            |  76 kB  00:00:00     
(9/32): perl-Getopt-Long-2.40-2.el7.noarch.rpm                                                                                                                                       |  56 kB  00:00:00     
(10/32): perl-HTTP-Tiny-0.033-3.el7.noarch.rpm                                                                                                                                       |  38 kB  00:00:00     
(11/32): perl-PathTools-3.40-5.el7.x86_64.rpm                                                                                                                                        |  82 kB  00:00:00     
(12/32): perl-Pod-Escapes-1.04-286.el7.noarch.rpm                                                                                                                                    |  50 kB  00:00:00     
(13/32): perl-Pod-Perldoc-3.20-4.el7.noarch.rpm                                                                                                                                      |  87 kB  00:00:00     
(14/32): perl-Pod-Simple-3.28-4.el7.noarch.rpm                                                                                                                                       | 216 kB  00:00:01     
(15/32): perl-Encode-2.51-7.el7.x86_64.rpm                                                                                                                                           | 1.5 MB  00:00:04     
(16/32): perl-Scalar-List-Utils-1.27-248.el7.x86_64.rpm                                                                                                                              |  36 kB  00:00:00     
(17/32): perl-Socket-2.010-3.el7.x86_64.rpm                                                                                                                                          |  49 kB  00:00:00     
(18/32): perl-Storable-2.45-3.el7.x86_64.rpm                                                                                                                                         |  77 kB  00:00:00     
(19/32): perl-Text-ParseWords-3.29-4.el7.noarch.rpm                                                                                                                                  |  14 kB  00:00:00     
(20/32): perl-Pod-Usage-1.63-3.el7.noarch.rpm                                                                                                                                        |  27 kB  00:00:00     
(21/32): perl-Time-HiRes-1.9725-3.el7.x86_64.rpm                                                                                                                                     |  45 kB  00:00:00     
(22/32): perl-Time-Local-1.2300-2.el7.noarch.rpm                                                                                                                                     |  24 kB  00:00:00     
(23/32): perl-constant-1.27-2.el7.noarch.rpm                                                                                                                                         |  19 kB  00:00:00     
(24/32): perl-macros-5.16.3-286.el7.x86_64.rpm                                                                                                                                       |  43 kB  00:00:00     
(25/32): perl-parent-0.225-244.el7.noarch.rpm                                                                                                                                        |  12 kB  00:00:00     
(26/32): perl-podlators-2.5.1-3.el7.noarch.rpm                                                                                                                                       | 112 kB  00:00:00     
(27/32): perl-threads-1.87-4.el7.x86_64.rpm                                                                                                                                          |  49 kB  00:00:00     
(28/32): perl-threads-shared-1.43-6.el7.x86_64.rpm                                                                                                                                   |  39 kB  00:00:00     
(29/32): perl-libs-5.16.3-286.el7.x86_64.rpm                                                                                                                                         | 687 kB  00:00:02     
(30/32): perl-5.16.3-286.el7.x86_64.rpm                                                                                                                                              | 8.0 MB  00:00:15     
(31/32): mysql-community-client-5.7.16-1.el7.x86_64.rpm                                                                                                                              |  24 MB  00:01:35     
(32/32): mysql-community-server-5.7.16-1.el7.x86_64.rpm                                                                                                                              | 152 MB  00:08:37     
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                                       366 kB/s | 192 MB  00:08:56     
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    : mysql57-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
Warning: RPMDB altered outside of yum.
  Installing : mysql-community-common-5.7.16-1.el7.x86_64                                                                                                                                              1/33 
  Installing : mysql-community-libs-5.7.16-1.el7.x86_64                                                                                                                                                2/33 
  Installing : mysql-community-client-5.7.16-1.el7.x86_64                                                                                                                                              3/33 
  Installing : 1:perl-parent-0.225-244.el7.noarch                                                                                                                                                      4/33 
  Installing : perl-HTTP-Tiny-0.033-3.el7.noarch                                                                                                                                                       5/33 
  Installing : perl-podlators-2.5.1-3.el7.noarch                                                                                                                                                       6/33 
  Installing : perl-Pod-Perldoc-3.20-4.el7.noarch                                                                                                                                                      7/33 
  Installing : 1:perl-Pod-Escapes-1.04-286.el7.noarch                                                                                                                                                  8/33 
  Installing : perl-Text-ParseWords-3.29-4.el7.noarch                                                                                                                                                  9/33 
  Installing : perl-Encode-2.51-7.el7.x86_64                                                                                                                                                          10/33 
  Installing : perl-Pod-Usage-1.63-3.el7.noarch                                                                                                                                                       11/33 
  Installing : 4:perl-libs-5.16.3-286.el7.x86_64                                                                                                                                                      12/33 
  Installing : 4:perl-macros-5.16.3-286.el7.x86_64                                                                                                                                                    13/33 
  Installing : perl-Storable-2.45-3.el7.x86_64                                                                                                                                                        14/33 
  Installing : perl-Exporter-5.68-3.el7.noarch                                                                                                                                                        15/33 
  Installing : perl-constant-1.27-2.el7.noarch                                                                                                                                                        16/33 
  Installing : perl-Time-Local-1.2300-2.el7.noarch                                                                                                                                                    17/33 
  Installing : perl-Socket-2.010-3.el7.x86_64                                                                                                                                                         18/33 
  Installing : perl-Carp-1.26-244.el7.noarch                                                                                                                                                          19/33 
  Installing : 4:perl-Time-HiRes-1.9725-3.el7.x86_64                                                                                                                                                  20/33 
  Installing : perl-PathTools-3.40-5.el7.x86_64                                                                                                                                                       21/33 
  Installing : perl-Scalar-List-Utils-1.27-248.el7.x86_64                                                                                                                                             22/33 
  Installing : perl-File-Temp-0.23.01-3.el7.noarch                                                                                                                                                    23/33 
  Installing : perl-File-Path-2.09-2.el7.noarch                                                                                                                                                       24/33 
  Installing : perl-threads-shared-1.43-6.el7.x86_64                                                                                                                                                  25/33 
  Installing : perl-threads-1.87-4.el7.x86_64                                                                                                                                                         26/33 
  Installing : perl-Filter-1.49-3.el7.x86_64                                                                                                                                                          27/33 
  Installing : 1:perl-Pod-Simple-3.28-4.el7.noarch                                                                                                                                                    28/33 
  Installing : perl-Getopt-Long-2.40-2.el7.noarch                                                                                                                                                     29/33 
  Installing : 4:perl-5.16.3-286.el7.x86_64                                                                                                                                                           30/33 
  Installing : mysql-community-server-5.7.16-1.el7.x86_64                                                                                                                                             31/33 
  Installing : mysql-community-libs-compat-5.7.16-1.el7.x86_64                                                                                                                                        32/33 
  Erasing    : 1:mariadb-libs-5.5.50-1.el7_2.x86_64                                                                                                                                                   33/33 
  Verifying  : perl-HTTP-Tiny-0.033-3.el7.noarch                                                                                                                                                       1/33 
  Verifying  : perl-threads-shared-1.43-6.el7.x86_64                                                                                                                                                   2/33 
  Verifying  : perl-Storable-2.45-3.el7.x86_64                                                                                                                                                         3/33 
  Verifying  : perl-Exporter-5.68-3.el7.noarch                                                                                                                                                         4/33 
  Verifying  : perl-constant-1.27-2.el7.noarch                                                                                                                                                         5/33 
  Verifying  : perl-PathTools-3.40-5.el7.x86_64                                                                                                                                                        6/33 
  Verifying  : 4:perl-libs-5.16.3-286.el7.x86_64                                                                                                                                                       7/33 
  Verifying  : 4:perl-macros-5.16.3-286.el7.x86_64                                                                                                                                                     8/33 
  Verifying  : 1:perl-Pod-Escapes-1.04-286.el7.noarch                                                                                                                                                  9/33 
  Verifying  : 1:perl-parent-0.225-244.el7.noarch                                                                                                                                                     10/33 
  Verifying  : 4:perl-5.16.3-286.el7.x86_64                                                                                                                                                           11/33 
  Verifying  : perl-File-Temp-0.23.01-3.el7.noarch                                                                                                                                                    12/33 
  Verifying  : 1:perl-Pod-Simple-3.28-4.el7.noarch                                                                                                                                                    13/33 
  Verifying  : perl-Time-Local-1.2300-2.el7.noarch                                                                                                                                                    14/33 
  Verifying  : perl-Pod-Perldoc-3.20-4.el7.noarch                                                                                                                                                     15/33 
  Verifying  : mysql-community-server-5.7.16-1.el7.x86_64                                                                                                                                             16/33 
  Verifying  : perl-Socket-2.010-3.el7.x86_64                                                                                                                                                         17/33 
  Verifying  : mysql-community-libs-5.7.16-1.el7.x86_64                                                                                                                                               18/33 
  Verifying  : perl-Carp-1.26-244.el7.noarch                                                                                                                                                          19/33 
  Verifying  : 4:perl-Time-HiRes-1.9725-3.el7.x86_64                                                                                                                                                  20/33 
  Verifying  : perl-Scalar-List-Utils-1.27-248.el7.x86_64                                                                                                                                             21/33 
  Verifying  : mysql-community-common-5.7.16-1.el7.x86_64                                                                                                                                             22/33 
  Verifying  : perl-Pod-Usage-1.63-3.el7.noarch                                                                                                                                                       23/33 
  Verifying  : perl-Encode-2.51-7.el7.x86_64                                                                                                                                                          24/33 
  Verifying  : perl-podlators-2.5.1-3.el7.noarch                                                                                                                                                      25/33 
  Verifying  : perl-Getopt-Long-2.40-2.el7.noarch                                                                                                                                                     26/33 
  Verifying  : perl-File-Path-2.09-2.el7.noarch                                                                                                                                                       27/33 
  Verifying  : perl-threads-1.87-4.el7.x86_64                                                                                                                                                         28/33 
  Verifying  : mysql-community-client-5.7.16-1.el7.x86_64                                                                                                                                             29/33 
  Verifying  : perl-Filter-1.49-3.el7.x86_64                                                                                                                                                          30/33 
  Verifying  : perl-Text-ParseWords-3.29-4.el7.noarch                                                                                                                                                 31/33 
  Verifying  : mysql-community-libs-compat-5.7.16-1.el7.x86_64                                                                                                                                        32/33 
  Verifying  : 1:mariadb-libs-5.5.50-1.el7_2.x86_64                                                                                                                                                   33/33 

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

Dependency Installed:
  mysql-community-client.x86_64 0:5.7.16-1.el7          mysql-community-common.x86_64 0:5.7.16-1.el7          perl.x86_64 4:5.16.3-286.el7                 perl-Carp.noarch 0:1.26-244.el7                  
  perl-Encode.x86_64 0:2.51-7.el7                       perl-Exporter.noarch 0:5.68-3.el7                     perl-File-Path.noarch 0:2.09-2.el7           perl-File-Temp.noarch 0:0.23.01-3.el7            
  perl-Filter.x86_64 0:1.49-3.el7                       perl-Getopt-Long.noarch 0:2.40-2.el7                  perl-HTTP-Tiny.noarch 0:0.033-3.el7          perl-PathTools.x86_64 0:3.40-5.el7               
  perl-Pod-Escapes.noarch 1:1.04-286.el7                perl-Pod-Perldoc.noarch 0:3.20-4.el7                  perl-Pod-Simple.noarch 1:3.28-4.el7          perl-Pod-Usage.noarch 0:1.63-3.el7               
  perl-Scalar-List-Utils.x86_64 0:1.27-248.el7          perl-Socket.x86_64 0:2.010-3.el7                      perl-Storable.x86_64 0:2.45-3.el7            perl-Text-ParseWords.noarch 0:3.29-4.el7         
  perl-Time-HiRes.x86_64 4:1.9725-3.el7                 perl-Time-Local.noarch 0:1.2300-2.el7                 perl-constant.noarch 0:1.27-2.el7            perl-libs.x86_64 4:5.16.3-286.el7                
  perl-macros.x86_64 4:5.16.3-286.el7                   perl-parent.noarch 1:0.225-244.el7                    perl-podlators.noarch 0:2.5.1-3.el7          perl-threads.x86_64 0:1.87-4.el7                 
  perl-threads-shared.x86_64 0:1.43-6.el7              

Replaced:
  mariadb-libs.x86_64 1:5.5.50-1.el7_2                                                                                                                                                                      

Complete!
[root@Service-1 ~]# rpm -qa |grep -i mysql
mysql57-community-release-el7-9.noarch
mysql-community-common-5.7.16-1.el7.x86_64
mysql-community-client-5.7.16-1.el7.x86_64
mysql-community-server-5.7.16-1.el7.x86_64
mysql-community-libs-5.7.16-1.el7.x86_64
mysql-community-libs-compat-5.7.16-1.el7.x86_64
[root@Service-1 ~]# ls
anaconda-ks.cfg                                 mysql-community-devel-5.7.16-1.el7.x86_64.rpm            mysql-community-libs-compat-5.7.16-1.el7.x86_64.rpm
mysql-5.7.16-1.el7.x86_64.rpm-bundle.tar        mysql-community-embedded-5.7.16-1.el7.x86_64.rpm         mysql-community-minimal-debuginfo-5.7.16-1.el7.x86_64.rpm
mysql57-community-release-el7-9.noarch.rpm      mysql-community-embedded-compat-5.7.16-1.el7.x86_64.rpm  mysql-community-server-5.7.16-1.el7.x86_64.rpm
mysql-community-client-5.7.16-1.el7.x86_64.rpm  mysql-community-embedded-devel-5.7.16-1.el7.x86_64.rpm   mysql-community-server-minimal-5.7.16-1.el7.x86_64.rpm
mysql-community-common-5.7.16-1.el7.x86_64.rpm  mysql-community-libs-5.7.16-1.el7.x86_64.rpm             mysql-community-test-5.7.16-1.el7.x86_64.rpm
[root@Service-1 ~]# ls -a
.                .bashrc                                         mysql-community-devel-5.7.16-1.el7.x86_64.rpm            mysql-community-minimal-debuginfo-5.7.16-1.el7.x86_64.rpm
..               .cshrc                                          mysql-community-embedded-5.7.16-1.el7.x86_64.rpm         mysql-community-server-5.7.16-1.el7.x86_64.rpm
anaconda-ks.cfg  mysql-5.7.16-1.el7.x86_64.rpm-bundle.tar        mysql-community-embedded-compat-5.7.16-1.el7.x86_64.rpm  mysql-community-server-minimal-5.7.16-1.el7.x86_64.rpm
.bash_history    mysql57-community-release-el7-9.noarch.rpm      mysql-community-embedded-devel-5.7.16-1.el7.x86_64.rpm   mysql-community-test-5.7.16-1.el7.x86_64.rpm
.bash_logout     mysql-community-client-5.7.16-1.el7.x86_64.rpm  mysql-community-libs-5.7.16-1.el7.x86_64.rpm             .tcshrc
.bash_profile    mysql-community-common-5.7.16-1.el7.x86_64.rpm  mysql-community-libs-compat-5.7.16-1.el7.x86_64.rpm
[root@Service-1 ~]# cd /var
[root@Service-1 var]# ls
adm  cache  crash  db  empty  games  gopher  kerberos  lib  local  lock  log  mail  nis  opt  preserve  run  spool  tmp  yp
[root@Service-1 var]# cd log
[root@Service-1 log]# ls
anaconda  audit  boot.log  btmp  cron  dmesg  dmesg.old  grubby  lastlog  maillog  messages  mysqld.log  ppp  secure  spooler  tallylog  tuned  wpa_supplicant.log  wtmp  yum.log
[root@Service-1 log]# more mysqld.log 
[root@Service-1 log]# cat mysqld.log 
[root@Service-1 log]# vi mysqld.log 
[root@Service-1 log]# clear
[root@Service-1 log]# ls
anaconda  audit  boot.log  btmp  cron  dmesg  dmesg.old  grubby  lastlog  maillog  messages  mysqld.log  ppp  secure  spooler  tallylog  tuned  wpa_supplicant.log  wtmp  yum.log
[root@Service-1 log]# grep 'temporary password' /var/log/mysqld.log
[root@Service-1 log]# mysql 
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
[root@Service-1 log]# mysql -u root
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
[root@Service-1 log]# mysql -u root -proot
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
[root@Service-1 log]# mysql -u root -p
Enter password: 
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
[root@Service-1 log]# service mysqld start
Redirecting to /bin/systemctl start  mysqld.service
[root@Service-1 log]# service mysqld status
Redirecting to /bin/systemctl status  mysqld.service
鈼[0m mysqld.service - MySQL Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: active (running) since Fri 2016-11-18 05:27:07 EST; 7s ago
  Process: 19999 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=0/SUCCESS)
  Process: 19926 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
 Main PID: 20003 (mysqld)
   CGroup: /system.slice/mysqld.service
           鈹斺攢20003 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid

Nov 18 05:27:04 Service-1 systemd[1]: Starting MySQL Server...
Nov 18 05:27:07 Service-1 systemd[1]: Started MySQL Server.
[root@Service-1 log]# ls
anaconda  audit  boot.log  btmp  cron  dmesg  dmesg.old  grubby  lastlog  maillog  messages  mysqld.log  ppp  secure  spooler  tallylog  tuned  wpa_supplicant.log  wtmp  yum.log
[root@Service-1 log]# more mysqld.log 
2016-11-18T10:27:04.807181Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2016-11-18T10:27:04.983628Z 0 [Warning] InnoDB: New log files created, LSN=45790
2016-11-18T10:27:05.016921Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2016-11-18T10:27:05.093764Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 8d1430e1-ad79-11e6-af1e-000c2922
771e.
2016-11-18T10:27:05.094938Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2016-11-18T10:27:05.095364Z 1 [Note] A temporary password is generated for root@localhost: ):WOR%jKq3ym
2016-11-18T10:27:07.859271Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2016-11-18T10:27:07.861769Z 0 [Note] /usr/sbin/mysqld (mysqld 5.7.16) starting as process 20003 ...
2016-11-18T10:27:07.864093Z 0 [Note] InnoDB: PUNCH HOLE support available
2016-11-18T10:27:07.864125Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2016-11-18T10:27:07.864130Z 0 [Note] InnoDB: Uses event mutexes
2016-11-18T10:27:07.864132Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2016-11-18T10:27:07.864134Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.3
2016-11-18T10:27:07.864136Z 0 [Note] InnoDB: Using Linux native AIO
2016-11-18T10:27:07.864328Z 0 [Note] InnoDB: Number of pools: 1
2016-11-18T10:27:07.864401Z 0 [Note] InnoDB: Using CPU crc32 instructions
2016-11-18T10:27:07.865759Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2016-11-18T10:27:07.876459Z 0 [Note] InnoDB: Completed initialization of buffer pool
2016-11-18T10:27:07.881350Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2016-11-18T10:27:07.889672Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
2016-11-18T10:27:07.897782Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2016-11-18T10:27:07.897849Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2016-11-18T10:27:07.909425Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2016-11-18T10:27:07.909925Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
2016-11-18T10:27:07.909931Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
2016-11-18T10:27:07.913512Z 0 [Note] InnoDB: Waiting for purge to start
2016-11-18T10:27:07.964314Z 0 [Note] InnoDB: 5.7.16 started; log sequence number 2532180
2016-11-18T10:27:07.965881Z 0 [Note] Plugin 'FEDERATED' is disabled.
2016-11-18T10:27:07.970550Z 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
2016-11-18T10:27:07.973779Z 0 [Note] InnoDB: Buffer pool(s) load completed at 161118  5:27:07
2016-11-18T10:27:07.990615Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.
2016-11-18T10:27:07.990766Z 0 [Warning] CA certificate ca.pem is self signed.
2016-11-18T10:27:07.992008Z 0 [Note] Server hostname (bind-address): '*'; port: 3306
2016-11-18T10:27:07.992147Z 0 [Note] IPv6 is available.
2016-11-18T10:27:07.992159Z 0 [Note]   - '::' resolves to '::';
2016-11-18T10:27:07.992176Z 0 [Note] Server socket created on IP: '::'.
2016-11-18T10:27:07.997781Z 0 [Note] Event Scheduler: Loaded 0 events
2016-11-18T10:27:07.997881Z 0 [Note] /usr/sbin/mysqld: ready for connections.
Version: '5.7.16'  socket: '/var/lib/mysql/mysql.sock'  port: 3306  MySQL Community Server (GPL)
[root@Service-1 log]# mysql
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
[root@Service-1 log]# mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.16

Copyright (c) 2000, 2016, 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> show variables like '%password%';
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql> show databases;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql> update user set password=password("zyf") where user="root";
ERROR 1046 (3D000): No database selected
mysql> use mysql
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql> set password = password('ZYFp#123');
Query OK, 0 rows affected, 1 warning (0.00 sec)

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

mysql> quit
Bye
[root@Service-1 log]# mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.16 MySQL Community Server (GPL)

Copyright (c) 2000, 2016, 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> quit
Bye
[root@Service-1 log]# 

 

 

posted @ 2016-11-15 20:07  大数据从业者FelixZh  阅读(876)  评论(0编辑  收藏  举报