腾讯云centos7安装mysql5.6

下载

[root@VM_0_2_centos ~]# wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
--2018-04-11 20:06:18--  http://dev.mysql.com/get/mysql-community-release-el7-5.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... 301 Moved Permanently
Location: https://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm [following]
--2018-04-11 20:06:19--  https://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
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//mysql-community-release-el7-5.noarch.rpm [following]
--2018-04-11 20:06:21--  https://repo.mysql.com//mysql-community-release-el7-5.noarch.rpm
Resolving repo.mysql.com (repo.mysql.com)... 23.57.113.239
Connecting to repo.mysql.com (repo.mysql.com)|23.57.113.239|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 6140 (6.0K) [application/x-redhat-package-manager]
Saving to: ‘mysql-community-release-el7-5.noarch.rpm’

100%[=====================================================================================================================================================>] 6,140       --.-K/s   in 0s      

2018-04-11 20:06:22 (717 MB/s) - ‘mysql-community-release-el7-5.noarch.rpm’ saved [6140/6140]

解压

[root@VM_0_2_centos ~]# rpm -ivh mysql-community-release-el7-5.noarch.rpm
Preparing...                          ################################# [100%]
Updating / installing...
   1:mysql-community-release-el7-5    ################################# [100%]

查看版本
yum repolist all | grep mysql

如果需要更换版本
# 禁用8.0
yum-config-manager --disable mysql80-community
# 启用5.7
yum-config-manager --enable mysql57-community
# 再查看一下
yum repolist all | grep mysql

安装,遇到选项输入y

[root@VM_0_2_centos ~]# yum install mysql-community-server
Loaded plugins: fastestmirror, langpacks
epel                                                                                                                                                                    | 4.7 kB  00:00:00     
extras                                                                                                                                                                  | 3.4 kB  00:00:00     
mysql-connectors-community                                                                                                                                              | 2.5 kB  00:00:00     
mysql-tools-community                                                                                                                                                   | 2.5 kB  00:00:00     
mysql56-community                                                                                                                                                       | 2.5 kB  00:00:00     
os                                                                                                                                                                      | 3.6 kB  00:00:00     
updates                                                                                                                                                                 | 3.4 kB  00:00:00     
(1/10): epel/7/x86_64/group_gz                                                                                                                                          | 266 kB  00:00:00     
(2/10): extras/7/x86_64/primary_db                                                                                                                                      | 185 kB  00:00:00     
(3/10): epel/7/x86_64/updateinfo                                                                                                                                        | 908 kB  00:00:00     
(4/10): os/7/x86_64/group_gz                                                                                                                                            | 156 kB  00:00:00     
(5/10): epel/7/x86_64/primary_db                                                                                                                                        | 6.3 MB  00:00:00     
(6/10): updates/7/x86_64/primary_db                                                                                                                                     | 6.9 MB  00:00:00     
(7/10): mysql-connectors-community/x86_64/primary_db                                                                                                                    |  18 kB  00:00:00     
(8/10): os/7/x86_64/primary_db                                                                                                                                          | 5.7 MB  00:00:00     
(9/10): mysql-tools-community/x86_64/primary_db                                                                                                                         |  39 kB  00:00:02     
(10/10): mysql56-community/x86_64/primary_db                                                                                                                            | 184 kB  00:00:04     
Determining fastest mirrors
Resolving Dependencies
--> Running transaction check
---> Package mysql-community-server.x86_64 0:5.6.39-2.el7 will be installed
--> Processing Dependency: mysql-community-common(x86-64) = 5.6.39-2.el7 for package: mysql-community-server-5.6.39-2.el7.x86_64
--> Processing Dependency: mysql-community-client(x86-64) >= 5.6.10 for package: mysql-community-server-5.6.39-2.el7.x86_64
--> Processing Dependency: perl(Data::Dumper) for package: mysql-community-server-5.6.39-2.el7.x86_64
--> Processing Dependency: perl(DBI) for package: mysql-community-server-5.6.39-2.el7.x86_64
--> Processing Dependency: libnuma.so.1(libnuma_1.2)(64bit) for package: mysql-community-server-5.6.39-2.el7.x86_64
--> Processing Dependency: libnuma.so.1(libnuma_1.1)(64bit) for package: mysql-community-server-5.6.39-2.el7.x86_64
--> Processing Dependency: libnuma.so.1()(64bit) for package: mysql-community-server-5.6.39-2.el7.x86_64
--> Running transaction check
---> Package mysql-community-client.x86_64 0:5.6.39-2.el7 will be installed
--> Processing Dependency: mysql-community-libs(x86-64) >= 5.6.10 for package: mysql-community-client-5.6.39-2.el7.x86_64
---> Package mysql-community-common.x86_64 0:5.6.39-2.el7 will be installed
---> Package numactl-libs.x86_64 0:2.0.9-6.el7_2 will be installed
---> Package perl-DBI.x86_64 0:1.627-4.el7 will be installed
--> Processing Dependency: perl(RPC::PlServer) >= 0.2001 for package: perl-DBI-1.627-4.el7.x86_64
--> Processing Dependency: perl(RPC::PlClient) >= 0.2000 for package: perl-DBI-1.627-4.el7.x86_64
---> Package perl-Data-Dumper.x86_64 0:2.145-3.el7 will be installed
--> Running transaction check
---> Package mariadb-libs.x86_64 1:5.5.52-1.el7 will be obsoleted
---> Package mysql-community-libs.x86_64 0:5.6.39-2.el7 will be obsoleting
---> Package perl-PlRPC.noarch 0:0.2020-14.el7 will be installed
--> Processing Dependency: perl(Net::Daemon) >= 0.13 for package: perl-PlRPC-0.2020-14.el7.noarch
--> Processing Dependency: perl(Net::Daemon::Test) for package: perl-PlRPC-0.2020-14.el7.noarch
--> Processing Dependency: perl(Net::Daemon::Log) for package: perl-PlRPC-0.2020-14.el7.noarch
--> Processing Dependency: perl(Compress::Zlib) for package: perl-PlRPC-0.2020-14.el7.noarch
--> Running transaction check
---> Package perl-IO-Compress.noarch 0:2.061-2.el7 will be installed
--> Processing Dependency: perl(Compress::Raw::Zlib) >= 2.061 for package: perl-IO-Compress-2.061-2.el7.noarch
--> Processing Dependency: perl(Compress::Raw::Bzip2) >= 2.061 for package: perl-IO-Compress-2.061-2.el7.noarch
---> Package perl-Net-Daemon.noarch 0:0.48-5.el7 will be installed
--> Running transaction check
---> Package perl-Compress-Raw-Bzip2.x86_64 0:2.061-3.el7 will be installed
---> Package perl-Compress-Raw-Zlib.x86_64 1:2.061-4.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===============================================================================================================================================================================================
 Package                                               Arch                                 Version                                      Repository                                       Size
===============================================================================================================================================================================================
Installing:
 mysql-community-libs                                  x86_64                               5.6.39-2.el7                                 mysql56-community                               2.0 M
     replacing  mariadb-libs.x86_64 1:5.5.52-1.el7
 mysql-community-server                                x86_64                               5.6.39-2.el7                                 mysql56-community                                59 M
Installing for dependencies:
 mysql-community-client                                x86_64                               5.6.39-2.el7                                 mysql56-community                                19 M
 mysql-community-common                                x86_64                               5.6.39-2.el7                                 mysql56-community                               257 k
 numactl-libs                                          x86_64                               2.0.9-6.el7_2                                os                                               29 k
 perl-Compress-Raw-Bzip2                               x86_64                               2.061-3.el7                                  os                                               32 k
 perl-Compress-Raw-Zlib                                x86_64                               1:2.061-4.el7                                os                                               57 k
 perl-DBI                                              x86_64                               1.627-4.el7                                  os                                              802 k
 perl-Data-Dumper                                      x86_64                               2.145-3.el7                                  os                                               47 k
 perl-IO-Compress                                      noarch                               2.061-2.el7                                  os                                              260 k
 perl-Net-Daemon                                       noarch                               0.48-5.el7                                   os                                               51 k
 perl-PlRPC                                            noarch                               0.2020-14.el7                                os                                               36 k

Transaction Summary
===============================================================================================================================================================================================
Install  2 Packages (+10 Dependent packages)

Total download size: 82 M
Is this ok [y/d/N]: y
Downloading packages:
warning: /var/cache/yum/x86_64/7/mysql56-community/packages/mysql-community-common-5.6.39-2.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY53 kB/s | 197 kB  00:09:08 ETA 
Public key for mysql-community-common-5.6.39-2.el7.x86_64.rpm is not installed
(1/12): mysql-community-common-5.6.39-2.el7.x86_64.rpm                                                                                                                  | 257 kB  00:00:01     
(2/12): mysql-community-libs-5.6.39-2.el7.x86_64.rpm                                                                                                                    | 2.0 MB  00:00:49     
warning: /var/cache/yum/x86_64/7/os/packages/numactl-libs-2.0.9-6.el7_2.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Public key for numactl-libs-2.0.9-6.el7_2.x86_64.rpm is not installed
(3/12): numactl-libs-2.0.9-6.el7_2.x86_64.rpm                                                                                                                           |  29 kB  00:00:00     
(4/12): perl-Compress-Raw-Bzip2-2.061-3.el7.x86_64.rpm                                                                                                                  |  32 kB  00:00:00     
(5/12): perl-Compress-Raw-Zlib-2.061-4.el7.x86_64.rpm                                                                                                                   |  57 kB  00:00:00     
(6/12): perl-Data-Dumper-2.145-3.el7.x86_64.rpm                                                                                                                         |  47 kB  00:00:00     
(7/12): perl-IO-Compress-2.061-2.el7.noarch.rpm                                                                                                                         | 260 kB  00:00:00     
(8/12): perl-Net-Daemon-0.48-5.el7.noarch.rpm                                                                                                                           |  51 kB  00:00:00     
(9/12): perl-PlRPC-0.2020-14.el7.noarch.rpm                                                                                                                             |  36 kB  00:00:00     
(10/12): perl-DBI-1.627-4.el7.x86_64.rpm                                                                                                                                | 802 kB  00:00:00     
(11/12): mysql-community-client-5.6.39-2.el7.x86_64.rpm                                                                                                                 |  19 MB  00:14:49     
(12/12): mysql-community-server-5.6.39-2.el7.x86_64.rpm                                                                                                                 |  59 MB  00:49:29     
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                           28 kB/s |  82 MB  00:50:20     
Retrieving key from file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Importing GPG key 0x5072E1F5:
 Userid     : "MySQL Release Engineering "
 Fingerprint: a4a9 4068 76fc bd3c 4567 70c8 8c71 8d3b 5072 e1f5
 Package    : mysql-community-release-el7-5.noarch (installed)
 From       : file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Is this ok [y/N]: y
Retrieving key from http://mirrors.tencentyun.com/centos/RPM-GPG-KEY-CentOS-7
Importing GPG key 0xF4A80EB5:
 Userid     : "CentOS-7 Key (CentOS 7 Official Signing Key) "
 Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
 From       : http://mirrors.tencentyun.com/centos/RPM-GPG-KEY-CentOS-7
Is this ok [y/N]: y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
  Installing : perl-Data-Dumper-2.145-3.el7.x86_64                                                                                                                                        1/13 
  Installing : mysql-community-common-5.6.39-2.el7.x86_64                                                                                                                                 2/13 
  Installing : mysql-community-libs-5.6.39-2.el7.x86_64                                                                                                                                   3/13 
  Installing : mysql-community-client-5.6.39-2.el7.x86_64                                                                                                                                 4/13 
  Installing : numactl-libs-2.0.9-6.el7_2.x86_64                                                                                                                                          5/13 
  Installing : 1:perl-Compress-Raw-Zlib-2.061-4.el7.x86_64                                                                                                                                6/13 
  Installing : perl-Net-Daemon-0.48-5.el7.noarch                                                                                                                                          7/13 
  Installing : perl-Compress-Raw-Bzip2-2.061-3.el7.x86_64                                                                                                                                 8/13 
  Installing : perl-IO-Compress-2.061-2.el7.noarch                                                                                                                                        9/13 
  Installing : perl-PlRPC-0.2020-14.el7.noarch                                                                                                                                           10/13 
  Installing : perl-DBI-1.627-4.el7.x86_64                                                                                                                                               11/13 
  Installing : mysql-community-server-5.6.39-2.el7.x86_64                                                                                                                                12/13 
  Erasing    : 1:mariadb-libs-5.5.52-1.el7.x86_64                                                                                                                                        13/13 
  Verifying  : mysql-community-server-5.6.39-2.el7.x86_64                                                                                                                                 1/13 
  Verifying  : perl-Compress-Raw-Bzip2-2.061-3.el7.x86_64                                                                                                                                 2/13 
  Verifying  : perl-Net-Daemon-0.48-5.el7.noarch                                                                                                                                          3/13 
  Verifying  : mysql-community-common-5.6.39-2.el7.x86_64                                                                                                                                 4/13 
  Verifying  : perl-Data-Dumper-2.145-3.el7.x86_64                                                                                                                                        5/13 
  Verifying  : mysql-community-libs-5.6.39-2.el7.x86_64                                                                                                                                   6/13 
  Verifying  : perl-PlRPC-0.2020-14.el7.noarch                                                                                                                                            7/13 
  Verifying  : 1:perl-Compress-Raw-Zlib-2.061-4.el7.x86_64                                                                                                                                8/13 
  Verifying  : numactl-libs-2.0.9-6.el7_2.x86_64                                                                                                                                          9/13 
  Verifying  : perl-DBI-1.627-4.el7.x86_64                                                                                                                                               10/13 
  Verifying  : perl-IO-Compress-2.061-2.el7.noarch                                                                                                                                       11/13 
  Verifying  : mysql-community-client-5.6.39-2.el7.x86_64                                                                                                                                12/13 
  Verifying  : 1:mariadb-libs-5.5.52-1.el7.x86_64                                                                                                                                        13/13 

Installed:
  mysql-community-libs.x86_64 0:5.6.39-2.el7                                                    mysql-community-server.x86_64 0:5.6.39-2.el7                                                   

Dependency Installed:
  mysql-community-client.x86_64 0:5.6.39-2.el7     mysql-community-common.x86_64 0:5.6.39-2.el7     numactl-libs.x86_64 0:2.0.9-6.el7_2       perl-Compress-Raw-Bzip2.x86_64 0:2.061-3.el7    
  perl-Compress-Raw-Zlib.x86_64 1:2.061-4.el7      perl-DBI.x86_64 0:1.627-4.el7                    perl-Data-Dumper.x86_64 0:2.145-3.el7     perl-IO-Compress.noarch 0:2.061-2.el7           
  perl-Net-Daemon.noarch 0:0.48-5.el7              perl-PlRPC.noarch 0:0.2020-14.el7               

Replaced:
  mariadb-libs.x86_64 1:5.5.52-1.el7                                                                                                                                                           

Complete!

启动mysql服务,进入查看一下,然后修改root密码(如果是mysql5.7则可以通过grep 'temporary password' /var/log/mysqld.log获取第一次安装的密码)

[root@VM_0_2_centos ~]# service mysql restart
Redirecting to /bin/systemctl restart  mysql.service
[root@VM_0_2_centos ~]# mysql -u root
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.39 MySQL Community Server (GPL)

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> select version();
+-----------+
| version() |
+-----------+
| 5.6.39    |
+-----------+
1 row in set (0.00 sec)
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
+--------------------+
3 rows in set (0.00 sec)
mysql> set password for 'root'@'localhost' = password('123456');
Query OK, 0 rows affected (0.00 sec)
mysql> exit
Bye

连接试试



报错了,原因:
1,防火墙是否开启3306
2,腾讯云安全组是否开放3306
3,mysql账户设置是否允许远程连接

[root@VM_0_2_centos ~]# service mysql restart
Redirecting to /bin/systemctl restart  mysql.service
[root@VM_0_2_centos ~]# systemctl firewalld status
Unknown operation 'firewalld'.
[root@VM_0_2_centos ~]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
   Active: inactive (dead)
     Docs: man:firewalld(1)
[root@VM_0_2_centos ~]# systemctl start firewalld
[root@VM_0_2_centos ~]# firewall-cmd --query-port=3360/tcp
no
[root@VM_0_2_centos ~]# firewall-cmd --query-port=80/tcp
no
[root@VM_0_2_centos ~]# firewall-cmd --zone=public --list-ports

[root@VM_0_2_centos ~]# firewall-cmd --zone=public --add-port=3306/tcp --permanent
success
[root@VM_0_2_centos ~]# firewall-cmd --zone=public --add-port=80/tcp --permanent
success
[root@VM_0_2_centos ~]# systemctl restart firewalld
[root@VM_0_2_centos ~]# firewall-cmd --zone=public --list-ports
3306/tcp 80/tcp

先重启一下mysql吧,然后查看firewalld是否启动,启动后看看端口号是否开放,
顺带把80端口也开放了
然后重启firewalld,再查看一下,还是不行
看下安全组吧,发现没有添加3306,那就加上吧



再看...



那就去设置允许远程连接吧...
mysql> grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option;
Query OK, 0 rows affected (0.00 sec)

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

GRANT ALL PRIVILEGES ON . TO '登录名'@'登录ip,%为任意地址' IDENTIFIED BY '登录密码' WITH GRANT OPTION;
记得刷新策略

OK,收工
mysql5.7可以参考这篇文章:https://www.cnblogs.com/bigbrotherer/p/7241845.html

你可能感兴趣的:(腾讯云centos7安装mysql5.6)