阿里云ECS下基于Centos7.4安装MySQL5.7.20
1、首先登录阿里云ECS服务器,如下图所示:

2、卸载MariaDB
说明:CentOS7.x默认安装MariaDB而不是MySQL,而且yum服务器上也移除了MySQL相关的软件包。因为MariaDB和MySQL可能会冲突,故先卸载MariaDB!

3、到mysql的官网下载最新版mysql的rpm集合包。
URL如下:https://downloads.mysql.com/archives/community/


4、进入/usr/local/src目录,使用lrzsz中的rz工具进行上传。


或者直接使用linux 下的wget工具进行下载:wget https://cdn.mysql.com/archives/mysql-5.7/mysql-5.7.20-1.el7.x86_64.rpm-bundle.tar(如果没有wget工具,使用yum install -y wget进行安装)


5、上传mysql-5.7.20-1.el7.x86_64.rpm-bundle.tar到Linux服务器,并解压tar包。


6、使用rpm -ivh命令进行安装。


安装过程中缺少依赖包libaio,使用 yum install -y libaio 进行安装。

再次使用rpm -ivh 安装

6、上面几个包有依赖关系,执行有先后顺序。
使用rpm安装方式安装mysql,安装的路径如下:
a. 数据库目录
/var/lib/mysql/
b. 配置文件
/usr/share/mysql(mysql.server命令及配置文件)
c. 相关命令
/usr/bin(mysqladmin mysqldump等命令)
d. 启动脚本
/etc/rc.d/init.d/(启动脚本文件mysql的目录)
e. /etc/my.conf(mysql数据库配置文件)
Xshell 5 (Build 1326)
Copyright (c) 2002-2017 NetSarang Computer, Inc. All rights reserved. Type `help' to learn how to use Xshell prompt.
[c:\~]$ Connecting to 47.95.234.20:22...
Connection established.
To escape to local shell, press 'Ctrl+Alt+]'. Last login: Mon Feb 19 10:27:46 2018 from 114.240.255.235 Welcome to Alibaba Cloud Elastic Compute Service ! [root@iZqmo9i3j77p7eZ ~]# cat /etc/redhat-release
CentOS Linux release 7.4.1708 (Core)
[root@iZqmo9i3j77p7eZ ~]# uname -a
Linux iZqmo9i3j77p7eZ 3.10.0-693.2.2.el7.x86_64 #1 SMP Tue Sep 12 22:26:13 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
[root@iZqmo9i3j77p7eZ ~]# rpm -qa | grep -i mariadb
mariadb-libs-5.5.56-2.el7.x86_64
[root@iZqmo9i3j77p7eZ ~]# rpm -e --nodeps mariadb-libs-5.5.56-2.el7.x86_64
[root@iZqmo9i3j77p7eZ ~]# rpm -qa | grep -i mariadb
[root@iZqmo9i3j77p7eZ ~]# cd /usr/local/src/
[root@iZqmo9i3j77p7eZ src]# yum install -y lrzsz
Loaded plugins: fastestmirror
base | 3.6 kB 00:00
epel | 4.7 kB 00:00
extras | 3.4 kB 00:00
mysql57-community | 2.5 kB 00:00
nginx | 2.9 kB 00:00
updates | 3.4 kB 00:00
(1/3): epel/x86_64/updateinfo | 882 kB 00:00
(2/3): epel/x86_64/primary_db | 6.2 MB 00:00
(3/3): mysql57-community/x86_64/primary_db | 134 kB 00:00
Determining fastest mirrors
* base: mirrors.aliyun.com
* epel: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
Package lrzsz-0.12.20-36.el7.x86_64 already installed and latest version
Nothing to do
[root@iZqmo9i3j77p7eZ src]# cd /usr/local/src/
[root@iZqmo9i3j77p7eZ src]# yum install -y lrzsz
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* epel: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
Package lrzsz-0.12.20-36.el7.x86_64 already installed and latest version
Nothing to do
[root@iZqmo9i3j77p7eZ src]# rz -y
[root@iZqmo9i3j77p7eZ ~]# ls
mysql-5.7.20-1.el7.x86_64.rpm-bundle.tar
[root@iZqmo9i3j77p7eZ ~]# tar xf mysql-5.7.20-1.el7.x86_64.rpm-bundle.tar -C /root/
[root@iZqmo9i3j77p7eZ ~]# ll
total 1158760
-rw-r--r-- 1 root root 593274880 Sep 14 23:52 mysql-5.7.20-1.el7.x86_64.rpm-bundle.tar
-rw-r--r-- 1 7155 31415 25090196 Sep 14 23:44 mysql-community-client-5.7.20-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 278300 Sep 14 23:44 mysql-community-common-5.7.20-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 3778120 Sep 14 23:44 mysql-community-devel-5.7.20-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 46238924 Sep 14 23:44 mysql-community-embedded-5.7.20-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 24077232 Sep 14 23:44 mysql-community-embedded-compat-5.7.20-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 128440800 Sep 14 23:44 mysql-community-embedded-devel-5.7.20-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 2238604 Sep 14 23:44 mysql-community-libs-5.7.20-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 2115892 Sep 14 23:44 mysql-community-libs-compat-5.7.20-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 55538708 Sep 14 23:44 mysql-community-minimal-debuginfo-5.7.20-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 171597916 Sep 14 23:45 mysql-community-server-5.7.20-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 15256460 Sep 14 23:45 mysql-community-server-minimal-5.7.20-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 118609776 Sep 14 23:45 mysql-community-test-5.7.20-1.el7.x86_64.rpm
[root@iZqmo9i3j77p7eZ ~]# rpm -ivh mysql-community-common-5.7.20-1.el7.x86_64.rpm
warning: mysql-community-common-5.7.20-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:mysql-community-common-5.7.20-1.e################################# [100%]
[root@iZqmo9i3j77p7eZ ~]# rpm -ivh mysql-community-libs-5.7.20-1.el7.x86_64.rpm
warning: mysql-community-libs-5.7.20-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:mysql-community-libs-5.7.20-1.el7################################# [100%]
[root@iZqmo9i3j77p7eZ ~]# rpm -ivh mysql-community-client-5.7.20-1.el7.x86_64.rpm
warning: mysql-community-client-5.7.20-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:mysql-community-client-5.7.20-1.e################################# [100%]
[root@iZqmo9i3j77p7eZ ~]# rpm -ivh mysql-community-server-5.7.20-1.el7.x86_64.rpm
warning: mysql-community-server-5.7.20-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
error: Failed dependencies:
libaio.so.1()(64bit) is needed by mysql-community-server-5.7.20-1.el7.x86_64
libaio.so.1(LIBAIO_0.1)(64bit) is needed by mysql-community-server-5.7.20-1.el7.x86_64
libaio.so.1(LIBAIO_0.4)(64bit) is needed by mysql-community-server-5.7.20-1.el7.x86_64
[root@iZqmo9i3j77p7eZ ~]# yum install -y libaio
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* epel: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
Resolving Dependencies
--> Running transaction check
---> Package libaio.x86_64 0:0.3.109-13.el7 will be installed
--> Finished Dependency Resolution Dependencies Resolved =============================================================================================================
Package Arch Version Repository Size
=============================================================================================================
Installing:
libaio x86_64 0.3.109-13.el7 base 24 k Transaction Summary
=============================================================================================================
Install 1 Package Total download size: 24 k
Installed size: 38 k
Downloading packages:
libaio-0.3.109-13.el7.x86_64.rpm | 24 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
** Found 2 pre-existing rpmdb problem(s), 'yum check' output follows:
2:postfix-2.10.1-6.el7.x86_64 has missing requires of libmysqlclient.so.18()(64bit)
2:postfix-2.10.1-6.el7.x86_64 has missing requires of libmysqlclient.so.18(libmysqlclient_18)(64bit)
Installing : libaio-0.3.109-13.el7.x86_64 1/1
Verifying : libaio-0.3.109-13.el7.x86_64 1/1 Installed:
libaio.x86_64 0:0.3.109-13.el7 Complete!
[root@iZqmo9i3j77p7eZ ~]# rpm -ivh mysql-community-server-5.7.20-1.el7.x86_64.rpm
warning: mysql-community-server-5.7.20-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:mysql-community-server-5.7.20-1.e################################# [100%]
[root@iZqmo9i3j77p7eZ ~]# cat /etc/passwd|grep mysql
mysql:x:27:27:MySQL Server:/var/lib/mysql:/bin/false
[root@iZqmo9i3j77p7eZ ~]# mysqld --initialize --user=mysql
[root@iZqmo9i3j77p7eZ ~]# cat /var/log/mysqld.log
2018-02-19T03:15:04.391013Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-02-19T03:15:06.462877Z 0 [Warning] InnoDB: New log files created, LSN=45790
2018-02-19T03:15:06.788535Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2018-02-19T03:15:06.852414Z 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: 15cbe9f9-1523-11e8-ac67-00163e08bafc.
2018-02-19T03:15:06.854816Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2018-02-19T03:15:06.855447Z 1 [Note] A temporary password is generated for root@localhost: monb3&s#kXfC#此处为MySQL生成的随机密码。
[root@iZqmo9i3j77p7eZ ~]# systemctl start mysqld.service
[root@iZqmo9i3j77p7eZ ~]# netstat -lntup|grep mysql
tcp6 0 0 :::3306 :::* LISTEN 8124/mysqld
[root@iZqmo9i3j77p7eZ ~]# ps -aux|grep mysql
mysql 8124 1.2 9.0 1125360 171300 ? Sl 11:16 0:00 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid
root 8158 0.0 0.0 112660 972 pts/1 R+ 11:16 0:00 grep --color=auto mysql
[root@iZqmo9i3j77p7eZ ~]# mysql -u root -h localhost -P 3306 -p#登录MySQL
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.20 Copyright (c) 2000, 2017, 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> set password = password('123456');#设置密码
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> grant all privileges on *.* to 'root'@'%' identified by '123456';#授权远程访问连接MySQL
Query OK, 0 rows affected, 1 warning (0.01 sec)
mysql> flush privileges;#将操作即时生效
Query OK, 0 rows affected (0.00 sec)
mysql> quit;
Bye
[root@iZqmo9i3j77p7eZ ~]# systemctl enable mysqld.service#加入开机自启动
阿里云ECS下基于Centos7.4安装MySQL5.7.20的更多相关文章
- [转]阿里云CentOS 7.1使用yum安装MySql5.6.24
阿里云CentOS 7.1使用yum安装MySql5.6.24 作者:vfhky | 时间:2015-06-25 09:43 | 分类:web 在前面两篇文章<2015博客升级记(四):Cent ...
- 解决阿里云ECS下kubeadm部署k8s无法指定公网IP
背景 一般情况下,"kubeadm"部署集群时指定"--apiserver-advertise-address=<public_ip>"参数,即可在 ...
- 阿里云ECS服务器(G5)安装配置docker
镜像下载.域名解析.时间同步请点击 阿里云开源镜像站 前言 服务器配置:阿里云ECS服务器(G5服务器3年2核8G内存80G云盘),安装的是CentOS,内核信息:5.10.60-9.al8.x86_ ...
- 阿里云ECS服务器上搭建keepalived+mha+mysql5.6+gtid+一主两从+脚本判断架构踩的坑
最近,公司项目搭建了一套后端数据库架构,不是在RDS,是在阿里云的ECS服务器上搭建keepalived.mha.mysql5.6.gtid.一主两从架构,目前还没有实现读写分离,以后架构升级,可能代 ...
- CentOS6.5和RedHat6.5下以rpm方式安装mysql-5.6.20
转帖;http://blog.csdn.net/mw08091020/article/details/39234207 a.检查下linux是不是已经安装了mysql rpm -qa | grep - ...
- 阿里云ECS下CentOS7.4 yum安装Python3.6环境
一.安装EPEL和IUS软件源 二.安装Python3.6 三.创建python3软链接连接符 四.安装pip3 五.创建pip3链接符 六.进行验证是否安装成功 一.安装EPEL和IUS软件源 yu ...
- 基于阿里云ecs(centos 7) 安装jenkins
1. 安装好 jdk 2. 官网(https://pkg.jenkins.io/redhat-stable/)下载rpm包(稳定版): wget https://pkg.jenkins.io/redh ...
- 阿里云ECS下Ubuntu 16.04系统安装python3.6.5 环境并设置为默认
一.添加python3.6安装包并安装: 二.修改系统默认python版本为3.6: 三.安装并升级pip版本: 一.添加python3.6安装包并安装: sudo apt-get install s ...
- 阿里云CentOS 7.1使用yum安装MySql5.6.24
正确的安装方法: 众所周知,Linux系统自带的repo是不会自动更新每个软件的最新版本(基本都是比较靠后的稳定版),所以无法通过yum方式安装MySQL的高级版本.所以我们需要先安装带有当前可用的m ...
随机推荐
- java提取(获取)博客信息(内容)
package com.wbg.my.service; import java.io.*; import java.net.HttpURLConnection; import java.net.URL ...
- 【洛谷P1363】幻象迷宫
P1363 幻想迷宫 显然,若从原图中起点走到相邻的图中对应的"起点"位置 ,就可以无限走下去, 若一个点从原图中可以到达,到了非原图中也可以到达,就可以无限走下去 我们不妨记录下 ...
- 【luogu P2071 座位安排】 题解
题目链接:https://www.luogu.org/problemnew/show/P2071#sub 邻接表 + 匈牙利 把之前的邻接矩阵匈牙利变成邻接表 要不然存不下... code: #inc ...
- Node.js 笔记03
一.buffer(缓存区) Node里面的buffer,是一个二进制数据容器,数据结构类似与数组,专门用于Node中数据的存放 1. buffer的基本使用 历史上的使用方式:const buf1 ...
- LINQ 方法
过滤操作符 Where 运算符(Linq扩展方法)根据给定条件过滤集合. 在其中扩展方法有以下两个重载.一个过载需要Func <TSource,bool>输入参数和第二个重载方法需要Fun ...
- 如何在Unity中显示FPS
using UnityEngine; using System.Collections; public class example : MonoBehaviour { public float upd ...
- js使用hover事件做一个“个人中心”的浮动层
原材料知识点:hover html: css:
- MarkDown/Html在线转换(支持代码高亮,可复制到微信公众号、今日头条)
MarkDown/Html在线转换能够将md渲染成html并且能保持代码高亮,可以方便的复制待格式的html粘贴到微信公众号,CSDN,简书,博客园,开源中国等. 扫码体验在线助手小程序 我是java ...
- HTML5--应用网页模板
因为刚开始写博客,只想着把知识点记录在这,也想给你们一些参考,在布局上有些没有思考太多;回过头来看,实在是不忍直视,对不住之前阅读的100+,既然昨天的事无法挽回,那就从现在开始从新整改吧!也希望大家 ...
- 利用css transition属性实现一个带动画显隐的微信小程序部件
我们先来看效果图 像这样的一个带过渡效果的小部件在我们实际开发中的应用几率还是比较大的,但是在开发微信小程序的过程中可能有的小伙伴发现transition这个属性它不好使(下面说明)所以我们这个时候会 ...