二进制格式安装MySQL

下载二进制格式的mysql软件包

  1. 下载二进制格式的 mysql 软件包
[root@localhost ~]# cd /usr/src/
[root@localhost src]# wget https://downloads.mysql.com/archives/get/p/23/file/mysql-5.7.31-linux-glibc2.12-x86_64.tar.gz
.......
[root@localhost src]# ls
debug kernels mysql-5.7.31-linux-glibc2.12-x86_64.tar.gz
  1. 创建用户和组
[root@localhost ~]# groupadd -r mysql
[root@localhost ~]# useradd -M -r -s /sbin/nologin -g mysql mysql
  1. 解压软件至 /usr/local/
[root@localhost src]# tar zxvf mysql-5.7.31-linux-glibc2.12-x86_64.tar.gz -C /usr/local/
[root@localhost src]# ls /usr/local/
bin etc games include lib lib64 libexec mysql-5.7.31-linux-glibc2.12-x86_64 sbin share src #做个软连接,方便操作
[root@localhost local]# ln -s mysql-5.7.31-linux-glibc2.12-x86_64 mysql
[root@localhost local]# ll
total 0
drwxr-xr-x. 2 root root 6 Nov 5 2016 bin
drwxr-xr-x. 2 root root 6 Nov 5 2016 etc
drwxr-xr-x. 2 root root 6 Nov 5 2016 games
drwxr-xr-x. 2 root root 6 Nov 5 2016 include
drwxr-xr-x. 2 root root 6 Nov 5 2016 lib
drwxr-xr-x. 2 root root 6 Nov 5 2016 lib64
drwxr-xr-x. 2 root root 6 Nov 5 2016 libexec
lrwxrwxrwx. 1 root root 35 Jan 8 13:10 mysql -> mysql-5.7.31-linux-glibc2.12-x86_64
drwxr-xr-x. 9 7161 31415 129 Jun 2 2020 mysql-5.7.31-linux-glibc2.12-x86_64
drwxr-xr-x. 2 root root 6 Nov 5 2016 sbin
drwxr-xr-x. 5 root root 49 Dec 24 13:10 share
drwxr-xr-x. 2 root root 6 Nov 5 2016 src
  1. 修改目录 /usr/local/mysql 的属主属组
[root@localhost local]# chown -R mysql.mysql /usr/local/mysql*
[root@localhost local]# ll mysql
lrwxrwxrwx. 1 mysql mysql 35 Jan 8 13:10 mysql -> mysql-5.7.31-linux-glibc2.12-x86_64
  1. 添加环境变量
[root@localhost ~]# vim /etc/profile.d/mysql.sh
[root@localhost ~]# cat /etc/profile.d/mysql.sh
export PATH=/usr/local/mysql/bin:$PATH
[root@localhost ~]# source /etc/profile.d/mysql.sh
[root@localhost ~]# echo $PATH
/usr/local/mysql/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
  1. 建立数据存放目录
[root@localhost ~]# mkdir /opt/data
[root@localhost ~]# chown -R mysql.mysql /opt/data/
[root@localhost ~]# ll -d /opt/data/
drwxr-xr-x. 2 mysql mysql 6 Jan 8 13:41 /opt/data/
  1. 初始化数据库
[root@localhost ~]# mysqld --initialize --user=mysql --datadir=/opt/data --basedir=/usr/local/mysql
2021-01-08T05:50:23.963006Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2021-01-08T05:50:24.553478Z 0 [Warning] InnoDB: New log files created, LSN=45790
2021-01-08T05:50:24.657628Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2021-01-08T05:50:24.732822Z 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: 67142018-5175-11eb-b9fe-000c29decd5a.
2021-01-08T05:50:24.735150Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2021-01-08T05:50:25.814369Z 0 [Warning] CA certificate ca.pem is self signed.
2021-01-08T05:50:26.196255Z 1 [Note] A temporary password is generated for root@localhost: CkIqTt7arh+f #注意:最后的'CkIqTt7arh+f'是登陆数据库的零时密码,这个是随机的,切记要牢记!
[root@localhost ~]# echo 'CkIqTt7arh+f' > pass #做个备份,以免忘记
  1. 修改配置文件(没有就创建一个)
[root@localhost ~]# cp /etc/my.cnf /etc/my.cnf.bak         #先做个备份
[root@localhost ~]# vim /etc/my.cnf
[root@localhost ~]# cat /etc/my.cnf
[mysqld]
datadir=/opt/data
socket=/tmp/mysql.sock
basedir=/usr/local/mysql
port=3306
pid-file=/opt/data/mysql.pid
character-set-server=utf8
log-error=/var/log/mysqld.log
  1. 配置服务启动脚本
[root@localhost support-files]# pwd
/usr/local/mysql/support-files
[root@localhost support-files]# ls
magic mysqld_multi.server mysql-log-rotate mysql.server
[root@localhost support-files]# cp -a mysql.server /etc/init.d/mysqld
[root@localhost support-files]# vim /etc/init.d/mysqld
........
basedir=/usr/local/mysql #修改这两行参数
datadir=/opt/data
........
  1. 启动 mysql
[root@localhost ~]# service mysqld start
Starting MySQL. SUCCESS!
  1. 设置开机自动启动
[root@localhost ~]# chkconfig --list

Note: This output shows SysV services only and does not include native
systemd services. SysV configuration data might be overridden by native
systemd configuration. If you want to list systemd services use 'systemctl list-unit-files'.
To see services enabled on particular target use
'systemctl list-dependencies [target]'. netconsole 0:off 1:off 2:off 3:off 4:off 5:off 6:off
network 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@localhost ~]# chkconfig --add mysqld #添加开机自动启动
[root@localhost ~]# chkconfig --list Note: This output shows SysV services only and does not include native
systemd services. SysV configuration data might be overridden by native
systemd configuration. If you want to list systemd services use 'systemctl list-unit-files'.
To see services enabled on particular target use
'systemctl list-dependencies [target]'. mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
netconsole 0:off 1:off 2:off 3:off 4:off 5:off 6:off
network 0:off 1:off 2:on 3:on 4:on 5:on 6:off
  1. 修改密码
[root@localhost ~]# mysql -uroot -p'CkIqTt7arh+f'
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 3
Server version: 5.7.31 Copyright (c) 2000, 2020, 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> set password=password('123456');
Query OK, 0 rows affected, 1 warning (0.00 sec)

二进制格式安装MySQL的更多相关文章

  1. centos6下通用二进制格式安装MySQL过程

    1.首先确保主机的MySQL没有运行 #ss -tnl  //查看有没有80端口 或者 #service mysqld stop 2.添加mysql用户和组 #id mysql  //首先查看mysq ...

  2. 二进制包安装MySQL数据库

    1.1二进制包安装MySQL数据库 1.1.1 安装前准备(规范) [root@Mysql_server ~]# mkdir -p /home/zhurui/tools ##创建指定工具包存放路径 [ ...

  3. MySQL使用通用二进制格式安装

      CentOS7安装MySQL的方法之通用二进制格式          

  4. 二进制包安装Mysql

    (1).准备工作 前往mysql官网下载二进制安装包,https://dev.mysql.com/downloads/mysql/5.7.html#downloads(注意:选择操作系统时选Linux ...

  5. 二进制包安装MYSQL——

    yum install libaio -y #安装mysql依赖包tar zxf mysql-5.5.59-linux-glibc2.12-x86_64.tar.gz mv mysql-5.5.59- ...

  6. 二进制方式安装mysql

    下载官方打包好的rpm的集合 https://downloads.mysql.com/archives/get/file/mysql-5.7.20-1.el7.x86_64.rpm-bundle.ta ...

  7. Linux 二进制包安装MySQL的一些问题

    第一步:安装相关的依赖yum install perl-Data-Dumper 第二步:初始化mysql数据库的内部信息./scripts/mysql_install_db --basedir=/us ...

  8. mysql5.6.13通用二进制格式安装并使用amoeba实现对mysql5.6数据库读写分离

    proxy 192.168.8.39 master 192.168.8.40 slave 192.168.8.20 一.安装mysql-5.6.13服务器 安装包: mysql-5.6.13-linu ...

  9. CentOS 7使用通过二进制包安装MySQL 5.7.18

    安装依赖 yum install -y libaio 下载 wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.18-linux- ...

随机推荐

  1. 从零搭建一个IdentityServer——会话管理与登出

    在上一篇文章中我们介绍了单页应用是如何使用IdentityServer完成身份验证的,并且在讲到静默登录以及会话监听的时候都提到会话(Session)这一概念,会话指的是用户与系统之间交互过程,反过来 ...

  2. python进阶(一)变量与数据类型、python之禅

    一.变量: 1.变量组成:由数据.字母与下划线组合 2.不能以数字开头 3.python关键字与函数名不能作为变量名 4.当字符串变量中包含引号时,可使用单引号与双引号进行区分,或转义 print(& ...

  3. 北航OO第三单元作业总结(3.1~3.3)

    JML简介及相关工具链使用 1.JML规格描述语言介绍 本单元学习的内容是JML规格描述语言.我们知道,面向对象方法是一个抽象过程,需求者仅需关注方法的规格.规格是对一个方法/类/程序的外部可感知行为 ...

  4. 如何保证Redis的高并发和高可用?

    就是如果你用redis缓存技术的话,肯定要考虑如何用redis来加多台机器,保证redis是高并发的,还有就是如何让Redis保证自己不是挂掉以后就直接死掉了,redis高可用 redis高并发:主从 ...

  5. manjaro 手动调节屏幕亮度

    1 问题描述 manjaro版本20.0,桌面XFCE,设置之类的地方没有屏幕亮度调节的功能. 2 解决方案 解决方案来自arch wiki. 亮度由ACPI内核模块控制,这个模块的接口在以下位置: ...

  6. Box UVA - 1587

    Ivan works at a factory that produces heavy machinery. He has a simple job - he knocks up wooden box ...

  7. 【Spring】循环依赖

    @ 目录 循环依赖 是什么? Spring是如何解决的? 源码分析 细节 循环依赖 是什么? ​ 简单的来说就是对象a的属性中引用了对象b,对象b的属性中引用了对象c......最后引用到a. < ...

  8. junit+maven单元测试

    一.概念 junit是一个专门测试的框架 集合maven进行单元测试,可批量测试类中的大量方法是否符合预期 二.作用:单元测试:测试的内容是类中的方法,每一个方法都是独立测试的.方法是测试的基本单位. ...

  9. 漫画 | 公司测试因提Bug不规范,锒铛入狱~

    互联网人罪状系列 1.上班第一天,前端把后端告上县衙,还列了 5 宗罪 2. 程序员状告产品经理八大罪状 (上) 3.程序员状告产品经理八大罪状(下) 开发人员与测试人员的关系,就如同程序员与产品经理 ...

  10. CVE-2011-0104:Microsoft Office Excel 栈溢出漏洞修复分析

    0x01 前言 上一篇讲到了 CVE-2011-0104 漏洞的成因和分析的方法,并没有对修复后的程序做分析.之后在一次偶然的情况下,想看一看是怎么修复的,结果却发现了一些问题 环境:修复后的 EXC ...