3、linux 系统(阿里云ECS服务器)搭建mysql5.7 服务

环境

[root@iZayh3eg8rjhsjZ ~]# lsb_release -a
LSB Version:    :core-4.1-amd64:core-4.1-noarch
Distributor ID: CentOS
Description:    CentOS Linux release 7.6.1810 (Core) 
Release:        7.6.1810
Codename:       Core

详细操作步骤

1 确保服务器系统处于最新状态

[root@iZayh3eg8rjhsjZ ~]# yum -y update
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
···(此处省略很多很多)
Updated:
  perl.x86_64 4:5.16.3-294.el7_6          perl-Pod-Escapes.noarch 1:1.04-294.el7_6         perl-libs.x86_64 4:5.16.3-294.el7_6              perl-macros.x86_64 4:5.16.3-294.el7_6        
  systemd.x86_64 0:219-62.el7_6.2         systemd-libs.x86_64 0:219-62.el7_6.2             systemd-networkd.x86_64 0:219-62.el7_6.2         systemd-sysv.x86_64 0:219-62.el7_6.2         
  tzdata.noarch 0:2018i-1.el7            

Complete!

主要是看到最后面有 Complete 说明安装成功

2 重启服务器

[root@iZayh3eg8rjhsjZ ~]#  reboot
Connection timed out

3 确认是否已经安装 mysql

[root@iZayh3eg8rjhsjZ ~]#  yum list installed | grep mysql
# 如果已经安装,可以卸载

4 下载MySql安装包

[root@iZayh3eg8rjhsjZ ~]#  rpm -ivh http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
Retrieving http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
warning: /var/tmp/rpm-tmp.NpAFqn: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:mysql57-community-release-el7-8  ################################# [100%]

[root@iZayh3eg8rjhsjZ ~]#  yum list installed | grep mysql                                             
mysql57-community-release.noarch     el7-8                             installed

5 安装 MySql

[root@iZayh3eg8rjhsjZ ~]# yum install -y mysql-server
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
mysql-connectors-community                                                                                                                                        | 2.5 kB  00:00:00     
···(此处省略很多很多)
Installed:
  mysql-community-client.x86_64 0:5.7.25-1.el7 mysql-community-devel.x86_64 0:5.7.25-1.el7 mysql-community-libs.x86_64 0:5.7.25-1.el7 mysql-community-libs-compat.x86_64 0:5.7.25-1.el7
  mysql-community-server.x86_64 0:5.7.25-1.el7

Dependency Installed:
  libaio.x86_64 0:0.3.109-13.el7                                                       mysql-community-common.x86_64 0:5.7.25-1.el7                                                      

Replaced:
  mariadb.x86_64 1:5.5.60-1.el7_5                          mariadb-devel.x86_64 1:5.5.60-1.el7_5                          mariadb-libs.x86_64 1:5.5.60-1.el7_5                         

Complete!

主要是看到最后面有 Complete 说明安装成功

6 设置开机启动Mysql

[root@iZayh3eg8rjhsjZ ~]# systemctl enable mysqld.service

检查是否已经安装了开机自动启动

[root@iZayh3eg8rjhsjZ ~]# systemctl list-unit-files | grep mysqld
mysqld.service                                enabled 
mysqld@.service                               disabled

7 启动Mysql服务

[root@iZayh3eg8rjhsjZ ~]#  systemctl start mysqld.service

8 设置root密码

查询Mysql默认密码

[root@iZayh3eg8rjhsjZ ~]# grep 'temporary password' /var/log/mysqld.log
2019-01-31T06:55:04.807770Z 1 [Note] A temporary password is generated for root@localhost: **********)h

登陆后

[root@iZayh3eg8rjhsjZ ~]# mysql -u root -p
Enter password: (此处输入密码)
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.7.25

Copyright (c) 2000, 2019, 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> 

设置密码

mysql> set PASSWORD = PASSWORD('Abc123!_');
Query OK, 0 rows affected, 1 warning (0.00 sec)

9 开启远程登录,授权root远程登录

mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'Abc123!_' WITH GRANT OPTION;        
Query OK, 0 rows affected, 1 warning (0.00 sec)

命令立即执行生效

mysql>flush privileges;



作者:Spareribs
链接:https://www.jianshu.com/p/2dae9f8b4c8e
来源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值