腾讯云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 <mysql-build@oss.oracle.com>"
 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) <security@centos.org>"
 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

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 213,254评论 6 492
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 90,875评论 3 387
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 158,682评论 0 348
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 56,896评论 1 285
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 66,015评论 6 385
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 50,152评论 1 291
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 39,208评论 3 412
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 37,962评论 0 268
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 44,388评论 1 304
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 36,700评论 2 327
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 38,867评论 1 341
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 34,551评论 4 335
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 40,186评论 3 317
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 30,901评论 0 21
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,142评论 1 267
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 46,689评论 2 362
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 43,757评论 2 351

推荐阅读更多精彩内容