阿里云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数据库配置文件)

  1 Xshell 5 (Build 1326)
  2 Copyright (c) 2002-2017 NetSarang Computer, Inc. All rights reserved.
  3
  4 Type `help‘ to learn how to use Xshell prompt.
  5 [c:\~]$
  6
  7 Connecting to 47.95.234.20:22...
  8 Connection established.
  9 To escape to local shell, press ‘Ctrl+Alt+]‘.
 10
 11 Last login: Mon Feb 19 10:27:46 2018 from 114.240.255.235
 12
 13 Welcome to Alibaba Cloud Elastic Compute Service !
 14
 15 [[email protected] ~]# cat /etc/redhat-release
 16 CentOS Linux release 7.4.1708 (Core)
 17 [[email protected] ~]# uname -a
 18 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
 19 [[email protected] ~]# rpm -qa | grep -i mariadb
 20 mariadb-libs-5.5.56-2.el7.x86_64
 21 [[email protected] ~]# rpm -e --nodeps mariadb-libs-5.5.56-2.el7.x86_64
 22 [[email protected] ~]# rpm -qa | grep -i mariadb
 23 [[email protected] ~]# cd /usr/local/src/
 24 [[email protected] src]# yum install -y lrzsz
 25 Loaded plugins: fastestmirror
 26 base                                              | 3.6 kB     00:00
 27 epel                                              | 4.7 kB     00:00
 28 extras                                            | 3.4 kB     00:00
 29 mysql57-community                                 | 2.5 kB     00:00
 30 nginx                                             | 2.9 kB     00:00
 31 updates                                           | 3.4 kB     00:00
 32 (1/3): epel/x86_64/updateinfo                       | 882 kB   00:00
 33 (2/3): epel/x86_64/primary_db                       | 6.2 MB   00:00
 34 (3/3): mysql57-community/x86_64/primary_db          | 134 kB   00:00
 35 Determining fastest mirrors
 36  * base: mirrors.aliyun.com
 37  * epel: mirrors.aliyun.com
 38  * extras: mirrors.aliyun.com
 39  * updates: mirrors.aliyun.com
 40 Package lrzsz-0.12.20-36.el7.x86_64 already installed and latest version
 41 Nothing to do
 42 [[email protected] src]# cd /usr/local/src/
 43 [[email protected] src]# yum install -y lrzsz
 44 Loaded plugins: fastestmirror
 45 Loading mirror speeds from cached hostfile
 46  * base: mirrors.aliyun.com
 47  * epel: mirrors.aliyun.com
 48  * extras: mirrors.aliyun.com
 49  * updates: mirrors.aliyun.com
 50 Package lrzsz-0.12.20-36.el7.x86_64 already installed and latest version
 51 Nothing to do
 52 [[email protected] src]# rz -y
 53 [[email protected] ~]# ls
 54 mysql-5.7.20-1.el7.x86_64.rpm-bundle.tar
 55 [[email protected] ~]# tar xf mysql-5.7.20-1.el7.x86_64.rpm-bundle.tar -C /root/
 56 [[email protected] ~]# ll
 57 total 1158760
 58 -rw-r--r-- 1 root root  593274880 Sep 14 23:52 mysql-5.7.20-1.el7.x86_64.rpm-bundle.tar
 59 -rw-r--r-- 1 7155 31415  25090196 Sep 14 23:44 mysql-community-client-5.7.20-1.el7.x86_64.rpm
 60 -rw-r--r-- 1 7155 31415    278300 Sep 14 23:44 mysql-community-common-5.7.20-1.el7.x86_64.rpm
 61 -rw-r--r-- 1 7155 31415   3778120 Sep 14 23:44 mysql-community-devel-5.7.20-1.el7.x86_64.rpm
 62 -rw-r--r-- 1 7155 31415  46238924 Sep 14 23:44 mysql-community-embedded-5.7.20-1.el7.x86_64.rpm
 63 -rw-r--r-- 1 7155 31415  24077232 Sep 14 23:44 mysql-community-embedded-compat-5.7.20-1.el7.x86_64.rpm
 64 -rw-r--r-- 1 7155 31415 128440800 Sep 14 23:44 mysql-community-embedded-devel-5.7.20-1.el7.x86_64.rpm
 65 -rw-r--r-- 1 7155 31415   2238604 Sep 14 23:44 mysql-community-libs-5.7.20-1.el7.x86_64.rpm
 66 -rw-r--r-- 1 7155 31415   2115892 Sep 14 23:44 mysql-community-libs-compat-5.7.20-1.el7.x86_64.rpm
 67 -rw-r--r-- 1 7155 31415  55538708 Sep 14 23:44 mysql-community-minimal-debuginfo-5.7.20-1.el7.x86_64.rpm
 68 -rw-r--r-- 1 7155 31415 171597916 Sep 14 23:45 mysql-community-server-5.7.20-1.el7.x86_64.rpm
 69 -rw-r--r-- 1 7155 31415  15256460 Sep 14 23:45 mysql-community-server-minimal-5.7.20-1.el7.x86_64.rpm
 70 -rw-r--r-- 1 7155 31415 118609776 Sep 14 23:45 mysql-community-test-5.7.20-1.el7.x86_64.rpm
 71 [[email protected] ~]# rpm -ivh mysql-community-common-5.7.20-1.el7.x86_64.rpm
 72 warning: mysql-community-common-5.7.20-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
 73 Preparing...                          ################################# [100%]
 74 Updating / installing...
 75    1:mysql-community-common-5.7.20-1.e################################# [100%]
 76 [[email protected] ~]# rpm -ivh  mysql-community-libs-5.7.20-1.el7.x86_64.rpm
 77 warning: mysql-community-libs-5.7.20-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
 78 Preparing...                          ################################# [100%]
 79 Updating / installing...
 80    1:mysql-community-libs-5.7.20-1.el7################################# [100%]
 81 [[email protected] ~]# rpm -ivh mysql-community-client-5.7.20-1.el7.x86_64.rpm
 82 warning: mysql-community-client-5.7.20-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
 83 Preparing...                          ################################# [100%]
 84 Updating / installing...
 85    1:mysql-community-client-5.7.20-1.e################################# [100%]
 86 [[email protected] ~]# rpm -ivh mysql-community-server-5.7.20-1.el7.x86_64.rpm
 87 warning: mysql-community-server-5.7.20-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
 88 error: Failed dependencies:
 89     libaio.so.1()(64bit) is needed by mysql-community-server-5.7.20-1.el7.x86_64
 90     libaio.so.1(LIBAIO_0.1)(64bit) is needed by mysql-community-server-5.7.20-1.el7.x86_64
 91     libaio.so.1(LIBAIO_0.4)(64bit) is needed by mysql-community-server-5.7.20-1.el7.x86_64
 92 [[email protected] ~]# yum install -y libaio
 93 Loaded plugins: fastestmirror
 94 Loading mirror speeds from cached hostfile
 95  * base: mirrors.aliyun.com
 96  * epel: mirrors.aliyun.com
 97  * extras: mirrors.aliyun.com
 98  * updates: mirrors.aliyun.com
 99 Resolving Dependencies
100 --> Running transaction check
101 ---> Package libaio.x86_64 0:0.3.109-13.el7 will be installed
102 --> Finished Dependency Resolution
103
104 Dependencies Resolved
105
106 =============================================================================================================
107  Package                 Arch                    Version                         Repository             Size
108 =============================================================================================================
109 Installing:
110  libaio                  x86_64                  0.3.109-13.el7                  base                   24 k
111
112 Transaction Summary
113 =============================================================================================================
114 Install  1 Package
115
116 Total download size: 24 k
117 Installed size: 38 k
118 Downloading packages:
119 libaio-0.3.109-13.el7.x86_64.rpm                                                      |  24 kB  00:00:00
120 Running transaction check
121 Running transaction test
122 Transaction test succeeded
123 Running transaction
124 Warning: RPMDB altered outside of yum.
125 ** Found 2 pre-existing rpmdb problem(s), ‘yum check‘ output follows:
126 2:postfix-2.10.1-6.el7.x86_64 has missing requires of libmysqlclient.so.18()(64bit)
127 2:postfix-2.10.1-6.el7.x86_64 has missing requires of libmysqlclient.so.18(libmysqlclient_18)(64bit)
128   Installing : libaio-0.3.109-13.el7.x86_64                                                              1/1
129   Verifying  : libaio-0.3.109-13.el7.x86_64                                                              1/1
130
131 Installed:
132   libaio.x86_64 0:0.3.109-13.el7
133
134 Complete!
135 [[email protected] ~]# rpm -ivh mysql-community-server-5.7.20-1.el7.x86_64.rpm
136 warning: mysql-community-server-5.7.20-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
137 Preparing...                          ################################# [100%]
138 Updating / installing...
139    1:mysql-community-server-5.7.20-1.e################################# [100%]
140 [[email protected] ~]# cat /etc/passwd|grep mysql
141 mysql:x:27:27:MySQL Server:/var/lib/mysql:/bin/false
142 [[email protected] ~]# mysqld --initialize --user=mysql
143 [[email protected] ~]# cat /var/log/mysqld.log
144 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).
145 2018-02-19T03:15:06.462877Z 0 [Warning] InnoDB: New log files created, LSN=45790
146 2018-02-19T03:15:06.788535Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
147 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.
148 2018-02-19T03:15:06.854816Z 0 [Warning] Gtid table is not ready to be used. Table ‘mysql.gtid_executed‘ cannot be opened.
149 2018-02-19T03:15:06.855447Z 1 [Note] A temporary password is generated for [email protected]: monb3&s#kXfC#此处为MySQL生成的随机密码。
150 [[email protected] ~]# systemctl start mysqld.service
151 [[email protected] ~]# netstat -lntup|grep mysql
152 tcp6       0      0 :::3306                 :::*                    LISTEN      8124/mysqld
153 [[email protected] ~]# ps -aux|grep mysql
154 mysql     8124  1.2  9.0 1125360 171300 ?      Sl   11:16   0:00 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid
155 root      8158  0.0  0.0 112660   972 pts/1    R+   11:16   0:00 grep --color=auto mysql
156 [[email protected] ~]# mysql -u root -h localhost -P 3306 -p#登录MySQL
157 Enter password:
158 Welcome to the MySQL monitor.  Commands end with ; or \g.
159 Your MySQL connection id is 3
160 Server version: 5.7.20
161
162 Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
163
164 Oracle is a registered trademark of Oracle Corporation and/or its
165 affiliates. Other names may be trademarks of their respective
166 owners.
167
168 Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.
169 mysql> set password = password(‘123456‘);#设置密码
170 Query OK, 0 rows affected, 1 warning (0.00 sec)
171 mysql> grant all privileges on *.* to ‘root‘@‘%‘ identified by ‘123456‘;#授权远程访问连接MySQL
172 Query OK, 0 rows affected, 1 warning (0.01 sec)
173 mysql> flush privileges;#将操作即时生效
174 Query OK, 0 rows affected (0.00 sec)
175 mysql> quit;
176 Bye
177 [[email protected] ~]# systemctl enable mysqld.service#加入开机自启动

原文地址:https://www.cnblogs.com/tqtl911/p/8453609.html

时间: 2024-10-10 03:55:41

阿里云ECS下基于Centos7.4安装MySQL5.7.20的相关文章

centos7编译安装mysql5.7.20版本

centos7编译安装mysql5.7.20版本 遇到问题: 之前想在线上搭建mysql5.7.20版本找了很多文档都觉得写得不怎么完善,很多需要注意的错误点都提及,所以只好自己写一篇了!个人觉得最主要注意的是mysql的data目录一定不能漏了权限问题,还有的经常遇到mysql.sock文件的错误就是因为编译的时候指定的目录要小心,然后启动前在my.cnf文件里面定义一下问题就解决了.这是我写的时候遇到最多的问题. 一.进入mysql官网下载(www.mysql.org)mysql源安装包:

阿里云 linux下已有mysql安装phpmyadmin php apache2

之前一直用的Xftp4和Xshell5管理服务器,每次要对数据库就行修改,都得从命令行,非常不方便,因为对mysql命令行不是很熟悉. 最近想到用界面来管理mysql,因此就安装了phpmyadmin 之前的服务器上只有mysql 和 tomcat 首先安装Apacache2 搜索httpd-2.4.12.tar.gz,下载后用xftp上传到/usr/local/src目录下 cd /usr/local/src tar xvfz httpd-2.4.2-deps.tar.gz cd srclib

阿里云ECS服务器Ubuntu 16.04安装mysql

root账户登录服务器Ubuntu16.04 apt-get update apt-get install mysql-server mysql-client; 安装时会让你设置root密码,输入2次. 本地连接mysql测试: mysql -uroot -p****(****是安装时你设置的root密码) 远程连接: mysql默认是只允许本地主机访问127.0.0.1,并关闭了远程连接,所以安装之后打开远程连接,并修改配置允许其他ip访问. 第一步: vim /etc/mysql/mysql

CentOS6.5和RedHat6.5下以rpm方式安装mysql-5.6.20

转帖;http://blog.csdn.net/mw08091020/article/details/39234207 a.检查下linux是不是已经安装了mysql rpm -qa | grep -i mysql #如果安装了先卸载旧的版本 yum -y remove mysql... b.下载需要的安装包,下载地址: http://cdn.mysql.com/Downloads/MySQL-5.6/MySQL-client-5.6.20-1.el6.x86_64.rpm http://cdn

基于阿里云ecs(centos 7) 安装jenkins

1. 安装好 jdk 2. 官网(https://pkg.jenkins.io/redhat-stable/)下载rpm包(稳定版): wget https://pkg.jenkins.io/redhat-stable/jenkins-2.176.3-1.1.noarch.rpm 3.  rpm 命令安装:rpm -ivh jenkins-2.176.3-1.1.noarch.rpm (jenkins-2.176.3-1.1.noarch.rpm 是下载的版本,具体根据下载时版本定) 4. 修改

阿里云ECS使用04:xampp安装

XAMPP(Apache+MySQL+PHP+PERL)是一个功能强大的建 XAMPP 软件站集成软件包.这个软件包原来的名字是 LAMPP,但是为了避免误解,最新的几个版本就改名为 XAMPP 了.它可以在Windows.Linux.Solaris.Mac OS X 等多种操作系统下安装使用,支持多语言:英文.简体中文.繁体中文.韩文.俄文.日文等.下面介绍下xampp的安装: 1.下载 去xampp的官网 http://www.apachefriends.org 下载最新的版本,这里下载的是

阿里云ECS服务器Ubuntu 16.04安装nginx

root账户登录,不是root的话下面所有命令自行在前面加上 sudo以管理员权限运行. apt-get update   更新软件源 apt-get install nginx   安装nginx 安装之后浏览器输入服务器ip或者域名(买1个域名绑定ip)访问即可看到 whereis nginx 可看到输出了3个路径: nginx: /usr/sbin/nginx /etc/nginx /usr/share/nginx 其中/usr/share/nginx/html是默认的web目录,可以看到

阿里云CentOS 7.1使用yum安装MySql5.6.24

正确的安装方法: 众所周知,Linux系统自带的repo是不会自动更新每个软件的最新版本(基本都是比较靠后的稳定版),所以无法通过yum方式安装MySQL的高级版本.所以我们需要先安装带有当前可用的mysql5系列社区版资源的rpm包. 1.安装mysql资源rpm包rpm -Uvh http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm 查看可用资源:yum repolist enabled | grep "mysql

阿里云ECS(Ubuntu)下JDK、Tomcat、MySQL安装记录

今天六一儿童节,然后... ... ... ... 然后就是父亲节呀孩子们!!! ———————————————————————割———————————————————————— 同事需要JDK.Tomcat.MySQL云环境,以不正当理由机智地把锅甩给大姐大 基于本人近一个月来各种折腾阿里云,表示生无可恋/(ㄒoㄒ)/~~ ———————————————————————割++——————————————————————- 一.安装前准备 安装环境:阿里云ECS/Ubuntu14.04 x64