二进制格式安装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. Java中对象的生与灭- 核心篇

    前言 大家好啊,我是汤圆,今天给大家带来的是<Java中对象的生与灭- 核心篇>,希望对大家有帮助,谢谢 文章纯属原创,个人总结难免有差错,如果有,麻烦在评论区回复或后台私信,谢啦 简介 ...

  2. java面试-谈谈你对OOM的理解

    一.OOM(OutOfMemoryError): 对象无法释放或无法被垃圾回收,造成内存浪费,导致程序运行速度减慢,甚至系统崩溃等严重后果,就是内存泄漏.多个内存泄漏造成可使用内存变少,会导致内存溢出 ...

  3. Linux Nvidia显卡驱动安装

    1 概述 因为某些需要需要在Linux上安装显卡驱动,这里记录一下安装过程. 2 环境 Manjaro RTX 2060 3 下载驱动安装包 到官网上搜索下载即可,可以戳这里: 选择自己的显卡型号即可 ...

  4. Day14_82_反射机制输出整个类

    利用反射机制输出整个类 代码实例 import java.lang.reflect.Field; import java.lang.reflect.Modifier; public class Ref ...

  5. Jenkins 自动触发执行的配置

    1. 两种触发方式 2. jenkins 和 github 同步配置 ngrok 安装 webhook 配置 1. 两种触发条件 Jenkins 中建立的任务是可以设置自动触发,更进一步的实现自动化. ...

  6. kubernetes的Deployment, DaemonSet, Job 和 CronJob事例

    k8s kubernetes给node节点添加标签和删除node节点标签 Deployment配置文件exampledeploymentv1.yaml apiVersion: apps/v1 kind ...

  7. 1014 Waiting in Line

    Suppose a bank has N windows open for service. There is a yellow line in front of the windows which ...

  8. 『动善时』JMeter基础 — 2、JMeter的安装和启动

    1.安装Java环境 由于JMeter是纯Java的桌面应用程序,因此它的运行环境需要Java环境,即需要安装JDK或JRE.(也就是安装JDK环境) 步骤简要说明: 下载并安装JDK 配置环境变量 ...

  9. VScode 使用提示

    vscode 配置xdebug参考 vscode配置phpxdebug 未完,待续!

  10. chrom里面的performance 颜色

    在network里面,在network里面,在network里面(重要事件说三遍) : 1. HTML 文件为蓝色. 2. 脚本为黄色. 3. 样式表为紫色. 4. 媒体文件为绿色. 5. 其他资源为 ...