Fork me on GitHub

MySQL之快速部署测试环境

MySQL之快速部署测试环境

前言

利用MySQL官网的Yum部署方法快速部署指定版本的MySQL,用于满足日常工作中的环境搭建需求。

部署

概述

官网下载Yum包地址:https://dev.mysql.com/downloads/repo/yum/
官网文档:https://dev.mysql.com/doc/mysql-yum-repo-quick-guide/en/

配置

  • 第一步:Adding the MySQL Yum Repository

    1
    shell> sudo rpm -Uvh platform-and-version-specific-package-name.rpm
  • 第二步:Selecting a Release Series

    1
    2
    3
    4
    5
    shell> yum install -y yum-utils
    shell> yum repolist all | grep mysql
    shell> sudo yum-config-manager --disable mysql57-community
    shell> sudo yum-config-manager --enable mysql56-community
    shell> yum repolist enabled | grep mysql
  • 第三步:Starting the MySQL Server

    1
    shell> sudo yum install mysql-community-server
  • 第四步:Installing MySQL
    For EL7-based platforms, this is the preferred command:

    1
    2
    shell> sudo systemctl start mysqld.service
    shell> sudo systemctl status mysqld.service

注意5.5.x\5.6.x\5.7.x各个版本初始化密码设置情况

  • 第五步:Securing the MySQL Installation (for MySQL 5.6 only)

其他设置

  • 设置管理员密码

    1
    2
    3
    mysql> set password for root@localhost = password('123456');
    or
    mysql> update mysql.user set password='*050376F3855A67F5E2C6514FD3130B31006C1276' where user='root';
  • 删除空密码及空账号

    1
    mysql> delete from mysql.user where user='' or password='';
  • 设置常用账号密码

    1
    2
    3
    GRANT SELECT, RELOAD, FILE, LOCK TABLES, REPLICATION CLIENT ON *.* TO 'dump'@'localhost' IDENTIFIED BY PASSWORD '*024B8B8BF4949F99832C5C33CDDD68852053C6C4';
    GRANT SELECT, RELOAD, SHUTDOWN, PROCESS, FILE, LOCK TABLES, REPLICATION CLIENT ON *.* TO 'readonly'@'%' IDENTIFIED BY PASSWORD '*8F029D7CE5A334DDEADAA8AD89D611EF249B4E06';
    GRANT REPLICATION SLAVE ON *.* TO 'repl'@'%' IDENTIFIED BY PASSWORD '*369588B9F7C5AFC66468BA8E6F7E864942F61432';
  • 设置应用账号权限

    1
    2
    3
    4
    5
    6
    7
    8
    9
    mysql> select password('123456');
    +-------------------------------------------+
    | password('123456') |
    +-------------------------------------------+
    | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
    +-------------------------------------------+
    1 row in set (0.00 sec)
    mysql> grant all privileges on app_db.* to 'xxx'@'10.0.%' identified by password '*6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9';
    mysql> flush privileges;

最小化授权

参考资料

官网资料

======================================================
希望各位朋友支持一下

本文作者:dongsheng
本文地址https://mds1455975151.github.io/archives/f72695e7.html
版权声明:转载请注明出处!

坚持技术分享,您的支持将鼓励我继续创作!