Centos 6 / 7 官方源安装Mysql 5.7

1 检查当前系统是否有旧版本

# rpm -qa | grep mysql
mysql-libs-5.1.71-1.el6.x86_64

#  rpm -qa | grep MySQL

1.1 如有旧版本可以删除

# rpm -e  mysql-libs-5.1.71-1.el6.x86_64  --nodeps

2 下载MySQL官方 Yum Repository

根据系统下载6或7

(6) wget -i http://dev.mysql.com/get/mysql57-community-release-el6-7.noarch.rpm
(7) wget -i  http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm

如果发现证书错误需要添加参数:

wget --no-check-certificate  http://dev.mysql.com/get/mysql57-community-release-el6-7.noarch.rpm

3 安装和确认仓库内容

3.1 安装

# rpm -ivh mysql57-community-release-el6-7.noarch.rpm

3.2 检查有效仓库

# yum repolist enabled
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
repo id                                           repo name                                          status
base                                              CentOS-6 - Base                                    6,713
extras                                            CentOS-6 - Extras                                        47
mysql-connectors-community         MySQL Connectors Community                 129
mysql-tools-community                  MySQL Tools Community                              90
mysql57-community                       MySQL 5.7 Community Server                    396
updates                                         CentOS-6 - Updates                                 1,046
repolist: 8,421

3.3 查询安装版本

# yum list mysql-community*
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
Available Packages
mysql-community-client.i686                          5.7.30-1.el6                mysql57-community         
mysql-community-client.x86_64                        5.7.30-1.el6                mysql57-community         
mysql-community-common.i686                          5.7.30-1.el6                mysql57-community         
mysql-community-common.x86_64                        5.7.30-1.el6                mysql57-community         
mysql-community-devel.i686                           5.7.30-1.el6                mysql57-community         
mysql-community-devel.x86_64                         5.7.30-1.el6                mysql57-community         
mysql-community-embedded.i686                        5.7.30-1.el6                mysql57-community         
mysql-community-embedded.x86_64                      5.7.30-1.el6                mysql57-community         
mysql-community-embedded-devel.i686                  5.7.30-1.el6                mysql57-community         
mysql-community-embedded-devel.x86_64                5.7.30-1.el6                mysql57-community         
mysql-community-libs.i686                            5.7.30-1.el6                mysql57-community         
mysql-community-libs.x86_64                          5.7.30-1.el6                mysql57-community         
mysql-community-libs-compat.i686                     5.7.30-1.el6                mysql57-community         
mysql-community-libs-compat.x86_64                   5.7.30-1.el6                mysql57-community         
mysql-community-release.noarch                       el6-5                       mysql-connectors-community
mysql-community-server.x86_64                        5.7.30-1.el6                mysql57-community         
mysql-community-test.x86_64                          5.7.30-1.el6                mysql57-community

4 安装

# yum install mysql-server
Dependencies Resolved
===========================================================================================================
 Package                         Arch            Version                  Repository                  Size
===========================================================================================================
Installing:
 mysql-community-server          x86_64          5.7.30-1.el6             mysql57-community          162 M
Installing for dependencies:
 mysql-community-client            x86_64          5.7.30-1.el6             mysql57-community           25 M
 mysql-community-common          x86_64          5.7.30-1.el6             mysql57-community          370 k
 mysql-community-libs             x86_64          5.7.30-1.el6             mysql57-community          2.4 M
 numactl                             x86_64           2.0.9-2.el6               base                             74 k

Transaction Summary
===========================================================================================================
Install       5 Package(s)

Total download size: 189 M
Installed size: 905 M
Is this ok [y/N]:

5 数据库初始化

5.1 启动mysql 服务

# service mysqld start
Initializing MySQL database:       [  OK  ]
Starting mysqld:                          [  OK  ]

5.2 查看初始密码

# grep password /var/log/mysqld.log
 [Note] A temporary password is generated for root@localhost: l#.&dX3Hgade
 [Note] Access denied for user 'UNKNOWN_MYSQL_USER'@'localhost' (using password: NO)

5.3 登录

# mysql -u root -pl#.&dX3Hgade

Server version: 5.7.30
Copyright (c) 2000, 2020, 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>

5.4 更改初始密码(必须更改初始密码,默认策略大小写数字加特殊字符)

mysql> use mysql;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statemen

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'Password-8888';

5.5 确认和修改密码策略

mysql> show variables like '%password%';

# vi /etc/my.cnf
添加 validate_password_policy配置
选择 0(LOW),1(MEDIUM),2(STRONG)其中一种,选择2需要提供密码字典文件

# 添加validate_password_policy配置
validate_password_policy=0
# 关闭密码策略
validate_password = off

修改后重启服务

 5.6 添加远程管理权限

mysql > grant all privileges on *.* to 'root'@'192.168.1.1' identified by 'password' with grant option;

mysql > flush privileges;

Centos Yum 安装 Mysql 5.7的更多相关文章

  1. centos yum 安装 mysql

      centos7下使用yum安装mysql 时间:2015-03-07 21:26:20      阅读:87445      评论:0      收藏:1      [点我收藏+] 标签: Cen ...

  2. centos yum安装mysql

    查看有没有安装包 # yum list mysql 安装mysql客户端 # yum install mysql # yum list mysql-server 安装mysql 服务器端 # yum ...

  3. Centos yum 安装mysql报错 No package mysql-server available.

    这是因为大多数mysql-*的资源名称被mariadb-*重命名了 所以换成 yum install mariadb-server 就可以了 PS[摘自网络] MariaDB不仅仅是Mysql的一个替 ...

  4. 阿里云服务器Linux CentOS安装配置(三)yum安装mysql

    阿里云服务器Linux CentOS安装配置(三)yum安装mysql 1.执行yum安装mysql命令:yum -y install mysql-server mysql-devel 2.启动mys ...

  5. CentOS 7.0下使用yum安装MySQL

    CentOS7默认数据库是mariadb,配置等用着不习惯,因此决定改成mysql,但是CentOS7的yum源中默认好像是没有mysql的.为了解决这个问题,我们要先下载mysql的repo源. 1 ...

  6. centos yum 安装php mysql

    1 安装php7 查看 centos 版本 # cat /etc/centos-release 删除之前的 php 版本 # yum remove php* php-common rpm 安装 Php ...

  7. 使用yum方式在centOS上安装mysql

    1.操作系统及MySQL版本 1.1 操作系统版本 CentOS release 6.5 (Final) 1.2 MySQL版本 mysql-5.1.73-3.el6_5.x86_64mysql-li ...

  8. centOS Linux下用yum安装mysql

    centOS Linux下用yum安装mysql      第一篇:安装和配置MySQL   第一步:安装MySQL   [root@192 local]# yum -y install mysql- ...

  9. 在 CentOS 7.5 64位上使用 yum 安装 MySQL 8.0

    前段时间在 CentOS 7.5 64位上安装 MySQL 8.0.查了些资料,在这里记录一下详细的安装和设置步骤. 一.安装 使用yum安装MySQL之前需要先下载对应的.rpm文件,下载方法: 去 ...

随机推荐

  1. Python爬虫之-动态网页数据抓取

    什么是AJAX: AJAX(Asynchronouse JavaScript And XML)异步JavaScript和XML.过在后台与服务器进行少量数据交换,Ajax 可以使网页实现异步更新.这意 ...

  2. Andrew Ng机器学习算法入门((七):特征选择和多项式回归

    特征选择 还是回归到房价的问题.在最开始的问题中,我们假设房价与房屋面积有关,那么最开始对房价预测的时候,回归方程可能如下所示: 其中frontage表示的房子的长,depth表示的是房子的宽. 但长 ...

  3. 想要测试Dubbo接口?测试的关键点在哪里?

    Dubbo接口如何测试? 这个dubbo如何测试,dubbo接口测试什么玩意儿?   RPC的有一个类型,叫Dubbo接口. 那这个接口如何测试?测试的关键点在哪里? 这个面试问题,我觉得大家可能就有 ...

  4. [bug] Mysql 对实体 "characterEncoding" 的引用必须以 ';' 分隔符结尾。

    参考 https://blog.csdn.net/cherrycheng_/article/details/51251441?

  5. 什么是环境变量,Linux环境变量及作用 echo

    什么是环境变量,Linux环境变量及作用 < Linux命令的执行过程是怎样的?(新手必读)Linux PATH环境变量是什么,有什么用?(入门必读) > <Linux就该这么学&g ...

  6. python发送钉钉消息

    import requests import time import hashlib import hmac import base64 import re def SendMessage(messa ...

  7. 从CentOS7默认安装的/home中转移空间到根目录/ - LVM操作简明教程

    一.基础概念 Cent0S 7默认启用LVM2(Logical Volume Manager),把机器的一块硬盘分为两个区sda1和sda2,其中分区sda1作为系统盘/boot挂载,少量空间:sda ...

  8. gitlab的CI/CD实现

    环境准备: gitlab账号公网账号:代码仓库和编译器 目标机:装有docker和gitlab-runner环境的服务器(Linux或类unix机器,我使用的时centos 项目代码:testgola ...

  9. Redis 安装和启动

    Redis 安装 安装准备: redis 压缩包 官网下载地址:https://redis.io/download 安装步骤: 第一步:安装 gcc 编译器 官网发布的 Redis 压缩包是 C 语言 ...

  10. LINUX创建文件和目录的默认权限

    在linux中,一位用户在创建文件和目录时,对其具有的权限都是一样的,如需更改,需要chmod命令做相应的更改.为什么?其实是权限掩码起作用了. 权限掩码的作用就是规范初创文件和目录时候的权限设置,免 ...