二进制格式安装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. 常用Linux操作

    常用Linux操作 这里我使用的是Git进行的Linux操作,如果你有服务器.或者LInux系统可以直接尝试 首先保证自己电脑上成功安装好了Git,右键鼠标: 随便找一个文件夹(我这里使用的是桌面的G ...

  2. String类的使用2

    /*String:字符串,使用一对""引起来表示.1.String声明为final的,不可被继承2.String实现了Serializable接口:表示字符串是支持序列化的. 实现 ...

  3. Java(246-264)【List、Set】

    1.数据结构_栈 Stack先进后出 2.数据结构_队列 Queue先进先出 3.数据结构_数组 Array查询快.增删慢 需要创建一个新数组,将指定新元素存储在指定索引位置,再把原数组元素根 据索引 ...

  4. 如果你的application.properties中还存在明文密码----加密Spring Boot中的application.properties

    1 概述 什么?都2020年了还在Spring Boot的配置文件中写明文密码? 虽然是小项目,明文也没人看. 明文简单快捷方便啊!!! 你看直接用户名root密码123456多么简单!!! ... ...

  5. 单个java文件打成可执行jar包

    1 概述 使用JDK自带的jar与java将单个java文件打成可执行jar包并运行. 当然也可以使用IDE完成,使用Maven只需要一个简单的package,但是单个文件嘛,没必要这么"凶 ...

  6. C语言-内存函数的实现(一)之memcpy

    C语言中的内存函数有如下这些 memcpy memmove memcmp memset 下面看看memcpy函数 memcpy 我们想想,之前有那个字符串拷贝的函数,即strcpy函数.都有拷贝的函数 ...

  7. AdaBoostClassifier参数

    [AdaBoostClassifier] Adaboost-参数: base_estimator:基分类器,默认是决策树,在该分类器基础上进行boosting,理论上可以是任意一个分类器,但是如果是其 ...

  8. 1003 Emergency (25分)

    As an emergency rescue team leader of a city, you are given a special map of your country. The map s ...

  9. .Net之静态资源

    介绍 静态文件都存储在Core Web根目录中.默认目录是<content_root>/wwwroot,但可通过 UseWebRoot方法更改访问目录.而content_root是指web ...

  10. hdu1686 最大匹配次数 KMP

    题意:      给你两个串,问你串a在串b中出现了多少次. 思路:       直接匹配,KMP时匹配到匹配串的最后一个的时候不用跳出,直接匹配就行了,最后一个'/0'不会和目标串匹配,所以经过ne ...