zoukankan      html  css  js  c++  java
  • 01 Mysql简介以及搭建

    MySQL数据库介绍   

    MySQL是一种开放源代码的关系型数据库管理系统(RDBMS),MySQL数据库系统使用最常用的数据库管理语言--结构化查询语言(SQL)进行数据库管理。

    体积小、速度快、总体拥有成本低,尤其是开放源码这一特点

    官网及下载地址

    • 主页:https://www.oracle.com/mysql/index.html
    • 下载主页面:https://www.mysql.com/downloads/
    • 社区资源下载页面:https://dev.mysql.com/downloads/
    • MySQL社区版下载页面:https://dev.mysql.com/downloads/mysql/

     二进制安装mysql-5.7

    下载地址:https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.23-linux-glibc2.12-x86_64.tar.gz

    2.1.1 创建用户以及解压文件

    [root@Centos-node4 ~]# useradd mysql -s /sbin/nologin -M
    [root@Centos-node4 tools]# tar xf mysql-5.7.23-linux-glibc2.12-x86_64.tar.gz 
    [root@Centos-node4 tools]# chown -R mysql. mysql-5.7.23-linux-glibc2.12-x86_64
    [root@Centos-node4 tools]# mv mysql-5.7.23-linux-glibc2.12-x86_64 /usr/local/mysql-5.7
    [root@Centos-node4 tools]# ln -s /usr/local/mysql-5.7 /usr/local/mysql
    [root@Centos-node4 tools]# cd /usr/local/mysql
    [root@Centos-node4 mysql]# mkdir data
    [root@Centos-node4 mysql]# chown -R mysql. data
    [root@Centos-node4 mysql]# mkdir logs
    [root@Centos-node4 mysql]# chown -R mysql. logs/

    2.1.2 初始化数据目录

    [root@Centos-node4 mysql]# bin/mysqld --initialize --user=mysql --datadir=/usr/local/mysql/data 

    2018-08-26T14:53:03.038174Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
    2018-08-26T14:53:03.039636Z 1 [Note] A temporary password is generated for root@localhost: BcMA:lfXN2)D

    #root临时密码

    
    [root@Centos-node4 mysql]# echo $?
    0

    2.1.3 创建my.cnf配置文件

    [root@Docker jenkins]# cat /etc/my.cnf 
    # *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
    # *** default location during install, and will be replaced if you
    # *** upgrade to a newer version of MySQL.
    [client]
    port = 3306
    default-character-set=utf8
    [mysqld]
    # 一般配置选项
    basedir = /usr/local/mysql
    datadir = /usr/local/mysql/data
    port = 3306
    character-set-server=utf8
    default_storage_engine = InnoDB
    sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

    2.1.4 拷贝启动文件

    [root@Centos-node4 mysql]# cp support-files/mysql.server /etc/init.d/mysqld
    [root@Centos-node4 mysql]# chmod +x /etc/init.d/mysqld
    [root@Centos-node4 mysql]# vim /etc/init.d/mysqld
      basedir=/usr/local/mysql
      datadir=/usr/local/mysql/data

    2.1.5 启动测试并修改root密码

    [root@Docker bin]# ./mysql -uroot -p
    Enter password:   #临时密码
    
    mysql> set password=password('123456');
    Query OK, 0 rows affected, 1 warning (0.00 sec)
    
    mysql> flush privileges;
    Query OK, 0 rows affected (0.00 sec)

     2.1.5 设置环境变量以及开机启动

    [root@Docker bin]# vim /etc/profile
    export MYSQL_HOME=/usr/local/mysql
    export PATH=$PATH:$MYSQL_HOME/bin$PATH
    [root@Docker bin]# source /etc/profile
    
    [root@Docker bin]# chkconfig --add mysqld
    [root@Docker bin]# chkconfig --list mysqld
  • 相关阅读:
    XML-Signature 语法和签名
    ZooKeeper相关资料集锦
    分布式锁
    spring-boot 知识集锦
    Spring boot druid 多数据源配置
    常见 SQL 语句的加锁分析
    fastjson反序列化多层嵌套泛型类与java中的Type类型
    Clean ThreadLocals
    java AOP Before, After, AfterReturning, AfterThrowing, or Around 注解
    java 线程间的通信 (wait / notify / notifyAll)
  • 原文地址:https://www.cnblogs.com/yanshicheng/p/9535763.html
Copyright © 2011-2022 走看看