zoukankan      html  css  js  c++  java
  • centos7环境MySql安装手册与备份总结

    业精于勤而荒于嬉 行成于思而毁于随!

    MySQL截止今天(2020年10月14日)尚未闭源,MariaDB数据库管理系统是MySQL的一个分支。

    MySQL分为官方收费版,和官方发布的开源社区版,除特殊需求外,一般使用社区版即可。

    各版本比较官方说明:https://www.mysql.com/products/

     社区版下载:https://dev.mysql.com/downloads/mysql/

    文章有部分内容参考:https://blog.csdn.net/wudinaniya/article/details/81094578 在此非常感谢原作者

    进入安装

    解压后会有如下的文件结构

    注意:安装之前需要检查下 机器上是否已经装用Mysql的环境,因为Centos会默认自带MariaDB,里面的组件略有差异,需要先卸载

    查看旧版本MySql

    rpm -qa | grep mysql
    或
    yum list installed|grep mysql

    如果有请依次卸载掉

    使用 rpm 命令安装MySql组件

    第一步先安装: rpm -ivh mysql-community-common-5.7.26-1.el7.x86_64.rpm  注:ivh中, i-install安装;v-verbose进度条;h-hash哈希校验

    之后安装 lib,client,server

    至此安装完成

    ******注******

    1> 执行 yum remove mysql-libs   命令后,会自动删除掉 /etc/ 下的 my.cnf 文件
    2> 对于安装mysql组件,只有安装了 mysql-community-server-5.7.22-1.el7.x86_64.rpm 组件,才会:
    a). 在 /etc/下生成 my.cnf 文件 和 my.cnf.d 文件夹

    登录并创建MySql密码

    systemctl start mysqld.service    #启动mysql
    systemctl status mysqld.service  #查看mysql状态
    systemctl stop mysqld.service   #关闭mysql

    由于MySQL5.7.4之前的版本中默认是没有密码的,登录后直接回车就可以进入数据库,进而进行设置密码等操作。其后版本对密码等安全相关操作进行了一些改变,在安装过程中,会在安装日志中生成一个临时密码

    grep 'temporary password' /var/log/mysqld.log  #查看临时密码

     

    #修改密码
    alter user root@localhost identified by 'password111'

     在5.6后,mysql内置密码增强机制,低强度密码会报错:

    Step1: 更改策略,设置 validate_password_policy=0;

    mysql> set global validate_password_policy=0;   
    mysql> set global validate_password_length=1;

    不管设置  validate_password_length=1,还是2,3,4 ,‘有效密码长度’这个参数的实际值都是4。超过4后设置是多少实际就是多少。

    继续重设密码OK;

    授权其他机器远程

    查看当前授予过的权限

    use mysql;
    select user,host from user;

    mysql> show grants;
    grant all privileges on *.* to root@'%' identified by 'lkg@123'; 
    mysql> flush privileges; #刷新权限,使设置生效, OK

    Backup and Recovery(源自官网)

    官方地址:https://dev.mysql.com/doc/refman/5.7/en/backup-types.html

    Physical (Raw) Versus Logical Backups

    Physical backups consist of raw copies of the directories and files that store database contents. This type of backup is suitable for large, important databases that need to be recovered quickly when problems occur.

    Logical backups save information represented as logical database structure (CREATE DATABASECREATE TABLE statements) and content (INSERT statements or delimited-text files). This type of backup is suitable for smaller amounts of data where you might edit the data values or table structure, or recreate the data on a different machine architecture.

    Online Versus Offline Backups

    Online backups take place while the MySQL server is running so that the database information can be obtained from the server. Offline backups take place while the server is stopped. This distinction can also be described as hot” versus cold” backups; a warm” backup is one where the server remains running but locked against modifying data while you access database files externally.

     

  • 相关阅读:
    IIS 和 各个协议
    Hibernate 框架基本知识
    各类主流框架及设计模式简介
    PHP微信公众开发笔记(七)
    PHP微信公众开发笔记(六)
    《Programming in Lua 3》读书笔记(二十七)
    《Programming in Lua 3》读书笔记(二十八)
    《Programming in Lua 3》读书笔记(二十六)
    PHP微信公众开发笔记(五)
    PHP微信公众开发笔记(四)
  • 原文地址:https://www.cnblogs.com/life512/p/13812800.html
Copyright © 2011-2022 走看看