1. MySQL 5.7安装部署

2024-06-04 6442阅读

RDBMS关系型数据库管理系统

  • 一、RDBMS关系型数据库管理系统
    • 1、数据存储结构
    • 2、约束 constraint
      • 1)、域约束
      • 2)、检查性约束
      • 3)、主键约束 primary key
      • 4)、惟一键约束 unique key
      • 5)、外键约束 Foreign Key
      • 3、关系型数据库管理系统的软件
      • 二、MySQL 5.7安装部署
        • 1、安装MySQL软件仓库
        • 2、安装MySQL 5.7
        • 3、启动MySQL服务
        • 4、修改root用户密码
        • 5、测试连接登录数据库
        • 6、在防火墙中放行数据库服务
        • 三、MySQL配置文件解析
          • 1、配置文件 ---- /etc/my.cnf

            一、RDBMS关系型数据库管理系统

            1、数据存储结构

            数据

            记录 record

            字段 column

            2、约束 constraint

            1)、域约束

            在字段进行数据类型限制

            作用: 确保表中的某个字段的数据格式统一

            2)、检查性约束

            作用: 确保数据的合理性

            3)、主键约束 primary key

            作用:确保某一行的数据的惟一性

            不允许出现重复数据

            不允许为空

            注意: 一张表只能有一个主键

            4)、惟一键约束 unique key

            不允许重复、允许为空

            一张表中可以存在多个惟一键

            5)、外键约束 Foreign Key

            作用: 确保数据的完整性

            3、关系型数据库管理系统的软件

            开源软件

            MySQL、PostgreSQL

            MariaDB

            商业数据库

            Oracle

            SQL Server

            国产数据库

            阿里 OceanBase

            华为 GuassDB

            二、MySQL 5.7安装部署

            1、安装MySQL软件仓库

            [root@web ~]# wget http://repo.mysql.com/mysql57-community-release-el7.rpm 
            [root@web ~]# rpm -ivh mysql57-community-release-el7.rpm 
            warning: mysql57-community-release-el7.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
            Preparing...                          ################################# [100%]
            Updating / installing...
               1:mysql57-community-release-el7-11 ################################# [100%]
            [root@web ~]# ls /etc/yum.repos.d/
            CentOS-Base.repo  CentOS-Debuginfo.repo  CentOS-Media.repo    CentOS-Vault.repo          mysql-community.repo
            
            [root@web ~]# sed -ri '/gpgcheck/s|1|0|g' /etc/yum.repos.d/mysql-community.repo
            [root@web ~]# sed -ri '/gpgkey/d' /etc/yum.repos.d/mysql-community.repo
            

            2、安装MySQL 5.7

            [root@localhost ~]# yum install -y mysql-community-server 
            

            3、启动MySQL服务

            [root@localhost ~]# systemctl start mysqld
            [root@localhost ~]# systemctl enable mysqld
            [root@localhost ~]# netstat -antp | grep mysql
            tcp6       0      0 :::3306                 :::*                    LISTEN      7620/mysqld         
            [root@localhost ~]# ps -elf | grep mysql
            1 S mysql      7620      1  0  80   0 - 296199 poll_s 10:42 ?       00:00:00 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid
            

            4、修改root用户密码

            [root@web ~]# grep -i "password" /var/log/mysqld.log 
            2023-08-17T07:39:00.876344Z 1 [Note] A temporary password is generated for root@localhost: kjFL%6Iiy_sp
            [root@web ~]# 
            [root@web ~]# mysql -u root -p
            Enter password: 
            mysql> alter user 'root'@'localhost' identified by 'WWW.1.com';
            Query OK, 0 rows affected (0.00 sec)
            mysql> flush privileges;
            Query OK, 0 rows affected (0.00 sec)
            mysql> exit
            Bye
            

            5、测试连接登录数据库

            [root@localhost ~]# mysql -uroot -pWWW.1.com
            mysql: [Warning] Using a password on the command line interface can be insecure.
            Welcome to the MySQL monitor.  Commands end with ; or \g.
            Your MySQL connection id is 5
            Server version: 5.7.17 MySQL Community Server (GPL)
            Copyright (c) 2000, 2016, 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> exit
            

            6、在防火墙中放行数据库服务

            [root@localhost ~]# firewall-cmd --permanent --add-port=3306/tcp 
            success
            [root@localhost ~]# firewall-cmd --reload
            success
            [root@localhost ~]# firewall-cmd --list-all
            public (active)
              target: default
              icmp-block-inversion: no
              interfaces: ens33
              sources: 
              services: dhcpv6-client ssh
              ports: 3306/tcp
              protocols: 
              masquerade: no
              forward-ports: 
              source-ports: 
              icmp-blocks: 
              rich rules: 
            

            三、MySQL配置文件解析

            1、配置文件 ---- /etc/my.cnf

            • datadir=目录

              指定数据目录

              数据目录的属主、属组必须为mysql用户

            • socket=/var/lib/mysql/mysql.sock

              套接字文件

              作用: 接收本地客户端的访问请求

              如果要修改套接字文件的位置,会影响客户端的连接登录,为方便客户端连接登录,可以在配置文件中为客户端指定套接字文件

              [client]

              socket=/mysql/data/mysql.sock

              • log-error=

                指定错误日志

              • pid-file=

                指定pid文件


    免责声明:我们致力于保护作者版权,注重分享,被刊用文章因无法核实真实出处,未能及时与作者取得联系,或有版权异议的,请联系管理员,我们会立即处理! 部分文章是来自自研大数据AI进行生成,内容摘自(百度百科,百度知道,头条百科,中国民法典,刑法,牛津词典,新华词典,汉语词典,国家院校,科普平台)等数据,内容仅供学习参考,不准确地方联系删除处理! 图片声明:本站部分配图来自人工智能系统AI生成,觅知网授权图片,PxHere摄影无版权图库和百度,360,搜狗等多加搜索引擎自动关键词搜索配图,如有侵权的图片,请第一时间联系我们,邮箱:ciyunidc@ciyunshuju.com。本站只作为美观性配图使用,无任何非法侵犯第三方意图,一切解释权归图片著作权方,本站不承担任何责任。如有恶意碰瓷者,必当奉陪到底严惩不贷!

    目录[+]