码迷,mamicode.com
首页 > 数据库 > 详细

阿里云ECS下基于Centos7.4安装MySQL5.7.20

时间:2018-02-19 11:57:47      阅读:998      评论:0      收藏:0      [点我收藏+]

标签:mysql5.7   mbed   been   目录   val   图片   ota   随机   ext   

 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 [root@iZqmo9i3j77p7eZ ~]# cat /etc/redhat-release 
 16 CentOS Linux release 7.4.1708 (Core) 
 17 [root@iZqmo9i3j77p7eZ ~]# 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 [root@iZqmo9i3j77p7eZ ~]# rpm -qa | grep -i mariadb
 20 mariadb-libs-5.5.56-2.el7.x86_64
 21 [root@iZqmo9i3j77p7eZ ~]# rpm -e --nodeps mariadb-libs-5.5.56-2.el7.x86_64
 22 [root@iZqmo9i3j77p7eZ ~]# rpm -qa | grep -i mariadb
 23 [root@iZqmo9i3j77p7eZ ~]# cd /usr/local/src/
 24 [root@iZqmo9i3j77p7eZ 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 [root@iZqmo9i3j77p7eZ src]# cd /usr/local/src/
 43 [root@iZqmo9i3j77p7eZ 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 [root@iZqmo9i3j77p7eZ src]# rz -y
 53 [root@iZqmo9i3j77p7eZ ~]# ls
 54 mysql-5.7.20-1.el7.x86_64.rpm-bundle.tar
 55 [root@iZqmo9i3j77p7eZ ~]# tar xf mysql-5.7.20-1.el7.x86_64.rpm-bundle.tar -C /root/
 56 [root@iZqmo9i3j77p7eZ ~]# 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 [root@iZqmo9i3j77p7eZ ~]# 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 [root@iZqmo9i3j77p7eZ ~]# 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 [root@iZqmo9i3j77p7eZ ~]# 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 [root@iZqmo9i3j77p7eZ ~]# 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 [root@iZqmo9i3j77p7eZ ~]# 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 [root@iZqmo9i3j77p7eZ ~]# 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 [root@iZqmo9i3j77p7eZ ~]# cat /etc/passwd|grep mysql
141 mysql:x:27:27:MySQL Server:/var/lib/mysql:/bin/false
142 [root@iZqmo9i3j77p7eZ ~]# mysqld --initialize --user=mysql
143 [root@iZqmo9i3j77p7eZ ~]# 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 root@localhost: monb3&s#kXfC#此处为MySQL生成的随机密码。
150 [root@iZqmo9i3j77p7eZ ~]# systemctl start mysqld.service
151 [root@iZqmo9i3j77p7eZ ~]# netstat -lntup|grep mysql
152 tcp6       0      0 :::3306                 :::*                    LISTEN      8124/mysqld         
153 [root@iZqmo9i3j77p7eZ ~]# 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 [root@iZqmo9i3j77p7eZ ~]# 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 [root@iZqmo9i3j77p7eZ ~]# systemctl enable mysqld.service#加入开机自启动
View Code

 

阿里云ECS下基于Centos7.4安装MySQL5.7.20

标签:mysql5.7   mbed   been   目录   val   图片   ota   随机   ext   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!