本次mysql数据库安装采用二进制安装(免安装即绿色版),数据库版本是mysql5.7.26

 首先下载mysql安装包,然后上传服务器里,最后解压。

  卸载centos7自带的数据库软件包:

    [root@localhost mysql]# yum remove mariadb

 开始安装mysql:

  [root@localhost tools]# ll
  total 629756
  -rw-r--r-- 1 root root 644869837 Dec 11 15:35 mysql-5.7.26-linux-glibc2.12-x86_64.tar.gz

  [root@localhost tools]# tar xf mysql-5.7.26-linux-glibc2.12-x86_64.tar.gz

  [root@localhost tools]# mv mysql-5.7.26-linux-glibc2.12-x86_64 /application/mysql

  [root@localhost ~]# useradd -s /sbin/nologin mysql

    把如下内容太添加到/etc/profile末尾行,然后执行命令使生效:

      export PATH=/application/mysql/bin:$PATH

      [root@localhost ~]# source /etc/profile

    查看是否生效,使用命令查看Mysql版本:   

      [root@localhost ~]# mysql -V
      mysql Ver 14.14 Distrib 5.7.26, for linux-glibc2.12 (x86_64) using EditLine wrapper

    授权:

    [root@localhost ~]# chown -R mysql.mysql /application/*
    [root@localhost ~]# chown -R mysql.mysql /data

    初始化数据方式一:密码设置比较复杂

      创建mysql数据目录:

        [root@localhost ~]# mkdir /data/mysql/data -p

        [root@localhost ~]# chown -R mysql.mysql /data 

      注意:mysql错误日志默认在数据目录里,默认是主机名.err!!!

[root@localhost ~]# mysqld --initialize --user=mysql --basedir=/application/mysql --datadir=/data/mysql/data

2019-12-12T02:09:08.794620Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2019-12-12T02:09:12.036238Z 0 [Warning] InnoDB: New log files created, LSN=45790
2019-12-12T02:09:12.283068Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2019-12-12T02:09:12.346261Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 63c6e908-1c84-11ea-9a0c-000c29002b3d.
2019-12-12T02:09:12.693297Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2019-12-12T02:09:12.697614Z 1 [Note] A temporary password is generated for root@localhost: #vVZul3CIt_f

    初始化数据方式二:密码设置简便      

[root@localhost ~]# rm -rf /data/mysql/data/*
[root@localhost ~]# mysqld --initialize-insecure --user=mysql --basedir=/application/mysql --datadir=/data/mysql/data
2019-12-12T03:04:10.776764Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2019-12-12T03:04:12.401550Z 0 [Warning] InnoDB: New log files created, LSN=45790
2019-12-12T03:04:12.571184Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2019-12-12T03:04:12.637140Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 12e75191-1c8c-11ea-a008-000c29002b3d.
2019-12-12T03:04:12.640047Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2019-12-12T03:04:12.643946Z 1 [Warning] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.

   配置mysql配置文件: 

[root@localhost data]# cp /etc/my.cnf /tmp/my.cnf20191212bak

[root@localhost data]# >/etc/my.cnf   

[root@localhost data]# cat >> /etc/my.cnf<< EOF
 [mysqld]
 user=mysql
 basedir=/application/mysql
datadir=/data/mysql/data
 socket=/tmp/mysql.sock
 server_id=6
 port=3306
 [mysql]
 socket=/tmp/mysql.sock
> EOF

   启动mysql数据库:centos7启动mysql数据库有两种方式

      方式1:      

[root@localhost ~]# cp /application/mysql/support-files/mysql.server /etc/init.d/mysqld
[root@localhost ~]# service mysqld status
ERROR! MySQL is not running
[root@localhost ~]# service mysqld start
Starting MySQL.Logging to '/data/mysql/data/localhost.localdomain.err'.
. SUCCESS!

      方式2:编辑如下配置文件

[root@localhost ~]# more /usr/lib/systemd/system/mysqld.service
[Unit]
Description=MySQL Server
Documentation=man:mysqld(8)
Documentation=http://dev.mysql.com/doc/refman/en/using-systemd.html
After=network.target
After=syslog.target
[Install]
WantedBy=multi-user.target
[Service]
User=mysql
Group=mysql
ExecStart=/application/mysql/bin/mysqld --defaults-file=/etc/my.cnf

  启动mysql:

  [root@localhost ~]# systemctl start mysqld.service

  [root@localhost ~]# netstat -lnp |grep 3306
  tcp6 0 0 :::3306 :::* LISTEN 25994/mysqld

如何修改mysql 管理员(root)用户密码:

  [root@localhost ~]# mysqladmin -uroot -p password xxxxxxxxxx

  然后直接回车就OK了!

   

数据库-mysql01 简单介绍以及安装部署的更多相关文章

  1. 【Hadoop离线基础总结】Hue的简单介绍和安装部署

    目录 Hue的简单介绍 概述 核心功能 安装部署 下载Hue的压缩包并上传到linux解压 编译安装启动 启动Hue进程 hue与其他框架的集成 Hue与Hadoop集成 Hue与Hive集成 Hue ...

  2. 【Hadoop离线基础总结】impala简单介绍及安装部署

    目录 impala的简单介绍 概述 优点 缺点 impala和Hive的关系 impala如何和CDH一起工作 impala的架构及查询计划 impala/hive/spark 对比 impala的安 ...

  3. Storm介绍及安装部署

    本节内容: Apache Storm是什么 Apache Storm核心概念 Storm原理架构 Storm集群安装部署 启动storm ui.Nimbus和Supervisor 一.Apache S ...

  4. openresty开发系列10--openresty的简单介绍及安装

    openresty开发系列10--openresty的简单介绍及安装 一.Nginx优点 十几年前,互联网没有这么火,软件外包开发,信息化建设,帮助企业做无纸化办公,收银系统,工厂erp,c/s架构偏 ...

  5. Apache Solr 初级教程(介绍、安装部署、Java接口、中文分词)

    Python爬虫视频教程零基础小白到scrapy爬虫高手-轻松入门 https://item.taobao.com/item.htm?spm=a1z38n.10677092.0.0.482434a6E ...

  6. Kafka介绍及安装部署

    本节内容: 消息中间件 消息中间件特点 消息中间件的传递模型 Kafka介绍 安装部署Kafka集群 安装Yahoo kafka manager kafka-manager添加kafka cluste ...

  7. CocoaPods的简单介绍及安装和使用

    CocoaPods的简单介绍及安装和使用   一.CocoaPods是什么? 当你开发iOS应用时,会常常使用到非常多第三方开源类库.比方JSONKit.AFNetWorking等等. 可能某个类库又 ...

  8. hue框架介绍和安装部署

    大家好,我是来自内蒙古的小哥,我现在在北京学习大数据,我想把学到的东西分享给大家,想和大家一起学习 hue框架介绍和安装部署 hue全称:HUE=Hadoop User Experience 他是cl ...

  9. Mysql数据库的简单介绍与入门

    Mysql数据库的简单介绍与入门 前言 一.下载与安装 1.下载 官网下载MYSQL5.7.21版本,链接地址https://www.mysql.com/downloads/.下载流程图如下: 找到M ...

随机推荐

  1. 第15讲:嵌入式SQL语句(动态SQL)

    一.动态SQL概述 1. 静态SQL vs 动态SQL ①动态SQL是相对静态SQL而言的 ②静态SQL特点:SQL语句在程序中已经按要求写好,只需要把一些参数通过变量传递给SQL语句即可 specN ...

  2. SQL(一)简介

    select * from websites 使用的sql为: /* Navicat MySQL Data Transfer Source Server : 127.0.0.1 Source Serv ...

  3. ora-01489 字符串连接的结果过长 解决方案

    如下代码,使用listagg进行分组拼接时,常常会报 ora-01489 错误,造成该报错的主要原因是:oracle对字符变量的长度限制,正常情况下,oracle定义的varchar2类型变量的长度不 ...

  4. SQL Server 创建 修改 删除数据表

    1. 图形界面方式操作数据表 (1)创建和修改数据表 列名中如果有两个以上单词时,最好用下划线连接,否则可能会给将来的查询维护带来不便.我们公司美国佬做的数据库就很烦,所有列名都有空格,一旦忘记用方括 ...

  5. IDEA取消SVN关联 , 在重新分享项目

    IDEA取消SVN关联,在重新分享项目     安装插件 1.打开Intellij中工具栏File的setting(ctrl+alt+s),选择plugins,在右边搜索框输入“SVN”,搜索.选择“ ...

  6. 物联网架构成长之路(45)-容器管理平台Rancher

    0.前言 按照上一篇博客,我已经把需要下载的rancher docker 依赖镜像下载上传到Harbor了. 1. 安装 执行如下,实现一键安装 docker run -d --restart=unl ...

  7. erlang 资源

    https://github.com/ninenines https://github.com/drobakowski https://github.com/dizzyd

  8. python 使用队列实现线程同步

    #通过queue的方式进行线程间同步,Queue在底层通过实现了dqueue(双生队列,在字节码时实现了线程安全)实现了线程安全 from queue import Queue import time ...

  9. C# 消息队列之 RabbitMQ 基础入门

    Ø  简介 C# 实现消息队列的方式有很多种,比如:MSMQ.RabbitMQ.EQueue 等,本文主要介绍使用 RabbitMQ 实现消息队列的基础入门.包括如下内容: 1.   什么是消息队列? ...

  10. Autoware 培训笔记 No. 4——寻迹

    1. 前言 好多初创公司公布出来的视频明显都是寻迹的效果,不是说寻迹不好,相反可以证明,寻迹是自动技术开始的第一步. 自动驾驶寻迹:一种能够自动按照给定的路线(通常是采用不同颜色或者其他信号标记来引导 ...