MySQL8.0.33二进制包安装与部署

这篇具有很好参考价值的文章主要介绍了MySQL8.0.33二进制包安装与部署。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

官方文档



https://downloads.mysql.com/archives/community/

https://dev.mysql.com/doc/refman/8.1/en/binary-installation.html



官方文档操作步骤
# Preconfiguration setup
$> groupadd mysql
$> useradd -r -g mysql -s /bin/false mysql
# Beginning of source-build specific instructions
$> tar zxvf mysql-VERSION.tar.gz
$> cd mysql-VERSION
# Postinstallation setup
$> cd /usr/local/mysql
$> mkdir mysql-files
$> chown mysql:mysql mysql-files
$> chmod 750 mysql-files
$> bin/mysqld --initialize --user=mysql
$> bin/mysql_ssl_rsa_setup
$> bin/mysqld_safe --user=mysql &
# Next command is optional
$> cp support-files/mysql.server /etc/init.d/mysql.server

环境准备

[root@node01 ~]# yum remove mariadb
[root@node01 ~]# yum install libaio-devel -y
[root@node01 ~]# rm -rf /etc/my.cnf

创建用户组和用户



[root@node01 ~]# id mysql
id: mysql: no such user

[root@node01 ~]# groupadd -g 54321 mysql

[root@node01 ~]# useradd -r -g mysql -s /bin/false -u 54321 mysql
[root@node01 ~]# id mysql
uid=54321(mysql) gid=54321(mysql) groups=54321(mysql)

下载、解压缩、创建软链接



1、wget下载mysql

[root@node01 ~]# wget https://downloads.mysql.com/archives/get/p/23/file/mysql-8.0.33-linux-glibc2.12-x86_64.tar

2、解压缩

[root@node01 ~]# tar -xf mysql-8.0.33-linux-glibc2.12-x86_64.tar 
[root@node01 ~]# tar -xf mysql-8.0.33-linux-glibc2.12-x86_64.tar.xz -C /usr/local/cluster/


3、创建软链接
[root@node01 ~]# ln -s /usr/local/cluster/mysql-8.0.33-linux-glibc2.12-x86_64/ /usr/local/mysql


[root@node03 ~]# ll -h /usr/local/mysql/
total 292K
drwxr-xr-x  2 7161 31415 4.0K Mar 17 03:33 bin
drwxr-xr-x  2 7161 31415   38 Mar 17 03:33 docs
drwxr-xr-x  3 7161 31415  282 Mar 17 03:33 include
drwxr-xr-x  6 7161 31415  201 Mar 17 03:33 lib
-rw-r--r--  1 7161 31415 279K Mar 17 01:22 LICENSE
drwxr-xr-x  4 7161 31415   30 Mar 17 03:33 man
-rw-r--r--  1 7161 31415  666 Mar 17 01:22 README
drwxr-xr-x 28 7161 31415 4.0K Mar 17 03:33 share
drwxr-xr-x  2 7161 31415   77 Mar 17 03:33 support-files

创建数据目录

[root@node01 ~]# mkdir -p /data/mysql/3306/data
[root@node01 ~]# chown -R mysql:mysql /data/mysql/3306/data

参数配置



[root@node01 ~]# vim /etc/my.cnf

[client]

socket=/data/mysql/3306/data/mysql.sock
[mysql]
prompt="\\u@\\h [\\d]> "


[mysqld]
basedir=/usr/local/mysql
datadir=/data/mysql/3306/data
user=mysql
port=3306
pid-file=/data/mysql/3306/data/mysql.pid
socket=/data/mysql/3306/data/mysql.sock
log-error=/data/mysql/3306/data/mysql.err
log-timestamps=system

mysqlx_port=33060
mysqlx_socket=/data/mysql/3306/data/mysqlx.sock

初始化数据库

默认使用/etc/my.cnf参数文件
[root@node01 ~]# /usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf --user=mysql --initialize


看到日志输出显示临时密码说明初始化成功
[root@node01 ~]# more /data/mysql/3306/data/mysql.err | grep temporary
2023-07-28T14:32:43.094407+08:00 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: d&e:Vf=ss4D<

启动数据库


[root@node01 ~]# /usr/local/mysql/bin/mysqld_safe --defaults-file=/etc/my.cnf &
[1] 77851
[root@node01 ~]# 2023-07-28T06:33:14.981353Z mysqld_safe Logging to '/data/mysql/3306/data/mysql.err'.
2023-07-28T06:33:15.026927Z mysqld_safe Starting mysqld daemon with databases from /data/mysql/3306/data


[root@node01 ~]# ps -ef |grep mysql | grep -v grep
root      77851  69072  0 14:33 pts/1    00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --defaults-file=/etc/my.cnf
mysql     78013  77851 11 14:33 pts/1    00:00:03 /usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql --datadir=/data/mysql/3306/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/data/mysql/3306/data/mysql.err --pid-file=/data/mysql/3306/data/mysql.pid --socket=/data/mysql/3306/data/mysql.sock --port=3306

配置环境变量



[root@node01 ~]# vim .bash_profile 
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin

export PATH

export JAVA_HOME=/usr/local/cluster/jdk
export PATH=$PATH:$JAVA_HOME/bin
export MYSQL_HOME=/usr/local/mysql
export PATH=$PATH:$MYSQL_HOME/bin

[root@node01 ~]# source .bash_profile 

登录测试


登录成功
[root@node01 ~]# mysql -uroot -p -S /data/mysql/3306/data/mysql.sock
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.33

Copyright (c) 2000, 2023, Oracle and/or its affiliates.

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.

修改密码

[root@node01 ~]# mysql -uroot -p -S /data/mysql/3306/data/mysql.sock
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.33

Copyright (c) 2000, 2023, Oracle and/or its affiliates.

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.

root@localhost [(none)]> select * from mysql.user\G
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
root@localhost [(none)]> alter user 'root'@'localhost' identified by 'oracle';
Query OK, 0 rows affected (0.00 sec)

使用配置文件启动


修改配置文件/usr/local/mysql/support-files/mysql.server

通过查看配置文件/usr/local/mysql/support-files/mysql.server
basedir默认/usr/local/mysql
datadir默认/usr/local/mysql/data,修改为/data/mysql/3306/data
配置文件默认是/etc/my.cnf,不需要修改


经过测试datadir不需要修改,因为配置文件默认是/etc/my.cnf,参数中指定了datadir的具体值

[root@node01 ~]# vim /usr/local/mysql/support-files/mysql.server


basedir=/usr/local/mysql
datadir=/data/mysql/3306/data

if test -z "$basedir"
then
  basedir=/usr/local/mysql
  bindir=/usr/local/mysql/bin
  if test -z "$datadir"
  then
    datadir=/data/mysql/3306/data
  fi
  sbindir=/usr/local/mysql/bin
  libexecdir=/usr/local/mysql/bin
else
  bindir="$basedir/bin"
  if test -z "$datadir"
  then
    datadir="$basedir/data"
  fi
  sbindir="$basedir/sbin"
  libexecdir="$basedir/libexec"
fi




使用配置文件/usr/local/mysql/support-files/mysql.server启动

[root@node01 ~]# /usr/local/mysql/support-files/mysql.server start
Starting MySQL................ SUCCESS!

[root@node01 ~]# /usr/local/mysql/support-files/mysql.server status
 SUCCESS! MySQL running (102015)
 
[root@node01 ~]# /usr/local/mysql/support-files/mysql.server stop
Shutting down MySQL... SUCCESS! 

配置systemctl服务





[root@node01 ~]# vim /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
Type=notify
TimeoutSec=0

# Execute pre and post scripts as root
PermissionsStartOnly=true

# Start main service
#ExecStart=/usr/local/mysql/support-files/mysql.server start
ExecStart=/usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf $MYSQLD_OPTS

# Use this to switch malloc implementation
#EnvironmentFile=-/etc/sysconfig/mysql

# Sets open_files_limit
@LimitNOFILE = 5000

Restart=on-failure
RestartPreventExitStatus=1

PrivateTmp=false

加载服务
[root@node01 ~]# systemctl daemon-reload
设置开机自启
[root@node01 ~]# systemctl enable mysqld.service

[root@node01 ~]# systemctl start mysqld.service
[root@node01 ~]# systemctl status mysqld.service
[root@node01 ~]# systemctl stop mysqld.service

[root@node01 ~]# systemctl disable mysqld.service
[root@node01 ~]# systemctl is-enabled mysqld.service

[root@node01 ~]# systemctl status mysqld.service
● mysqld.service - MySQL Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; disabled; vendor preset: disabled)
   Active: inactive (dead)
     Docs: man:mysqld(8)
           http://dev.mysql.com/doc/refman/en/using-systemd.html

Jul 27 19:20:44 node01 systemd[1]: [/usr/lib/systemd/system/mysqld.service:28] Unknown lvalue '@LimitNOFILE' in section 'Service'

启动mysql
[root@node01 ~]# systemctl start mysqld.service
[root@node01 ~]# systemctl status mysqld.service
● mysqld.service - MySQL Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; disabled; vendor preset: disabled)
   Active: active (running) since Thu 2023-07-27 19:24:00 CST; 2s ago
     Docs: man:mysqld(8)
           http://dev.mysql.com/doc/refman/en/using-systemd.html
  Process: 113461 ExecStart=/usr/local/mysql/support-files/mysql.server start (code=exited, status=0/SUCCESS)
 Main PID: 113725 (mysqld)
    Tasks: 39
   Memory: 291.3M
   CGroup: /system.slice/mysqld.service
           ├─113474 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/data/mysql --pid-file=/data/mysql/mysql.pid
           └─113725 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/data/mysql --plugin-dir=/usr/local/mysql/li...

Jul 27 19:23:59 node01 systemd[1]: Starting MySQL Server...
Jul 27 19:24:00 node01 systemd[1]: mysqld.service: Supervising process 113725 which is not our child. We'll most likely no... exits.
Jul 27 19:24:00 node01 systemd[1]: Started MySQL Server.
Hint: Some lines were ellipsized, use -l to show in full.

[root@node01 ~]# ps -ef |grep mysql
mysql    113474      1  0 19:23 ?        00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/data/mysql --pid-file=/data/mysql/mysql.pid
mysql    113725 113474  4 19:23 ?        00:00:00 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/data/mysql --plugin-dir=/usr/local/mysql/lib/plugin --log-error=/data/mysql/mysql.err --pid-file=/data/mysql/mysql.pid --port=3306
root     113895 107141  0 19:24 pts/1    00:00:00 grep --color=auto mysql


配置文件最终版



[root@node01 ~]# 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
Type=notify
TimeoutSec=0

# Execute pre and post scripts as root
PermissionsStartOnly=true

# Start main service
ExecStart=/usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf $MYSQLD_OPTS

# Use this to switch malloc implementation
#EnvironmentFile=-/etc/sysconfig/mysql

# Sets open_files_limit
@LimitNOFILE = 5000

Restart=on-failure
RestartPreventExitStatus=1

PrivateTmp=false

文章来源地址https://www.toymoban.com/news/detail-638943.html

到了这里,关于MySQL8.0.33二进制包安装与部署的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • 【大数据之Hive】三、Linux下安装MySQL8.0.33

    (1)解压MySQL安装包: (2)卸载系统自带的mariadb: (3)安装MySQL依赖(一定要按顺序装): (4)安装mysql-client: (5)安装mysql-server: 解决方法:用yum直接下载 (6)启动MySQL: (7)查看MySQL密码: 配置需求:   root用户 + 123456,实现在任何主机上都能登录MySQL数据库。

    2024年02月09日
    浏览(47)
  • Centos7.9_或者华为OpenEuler安装Mysql8.0.33安装_亲测成功---Linux工作笔记061

    看一下我们的安装包. 错误命令不用管,然后我们来看一下,是否有mariadb这个包,可以看到已经安装了

    2024年02月13日
    浏览(47)
  • MySQL8.0.33主从复制配置记录

    官网:https://dev.mysql.com/downloads/mysql/ 在线下载或者下载到本地再上传 准备wget下载工具: 进入MySQL的bin目录 初始化并得到密码 ./mysqld: error while loading shared libraries: libnuma.so.1: cannot open shared object file: No such file or directory 报错,缺依赖:::: yum install -y libaio yum -y install numactl 再初始

    2024年02月02日
    浏览(44)
  • 二进制包安装mysql

    1.先查看系统中是否已存在mysql,存在将其卸载 2.环境清理 清空PATH有关的mysql 注释掉之前的$PATH 没有就跳过这步 3.安装所需的基础依赖 4.创建用户 mysql官网下载 1.下载二进制安装包 自行选择一个下载目录 这里我下载到/opt下 4.解压到/usr/local/ 5.mysql下面没有data目录则创建 6.修

    2024年02月12日
    浏览(43)
  • (六)Kubernetes - 手动部署(二进制方式安装)

    可参考以下链接,了解nginx和keepalived,不看也不影响部署 CHAPTER 3 Web HA集群部署 - Keepalived CHAPTER 1 Web Server - nginx 安装配置 Nginx是一个主流Web服务和反向代理服务器,这里用四层实现对apiserver实现负载均衡。 Keepalived是一个主流高可用软件,基于VIP绑定实现服务器双机热备,在

    2024年02月04日
    浏览(48)
  • K8s集群部署(二进制安装部署详细手册)

       一、简介 K8s部署主要有两种方式: 1、Kubeadm Kubeadm是一个K8s部署工具,提供kubeadm init和kubeadm join,用于快速部署Kubernetes集群。 2、二进制   从github下载发行版的二进制包,手动部署每个组件,组成Kubernetes集群。  本文通过二进制安装部署的方式在centos7上搭建kubernetes集群

    2024年02月15日
    浏览(50)
  • 01-mysql安装篇(rpm方式安装+二进制方式安装)

    1、检查是否安装了mariadb 卸载清除: rpm -e 文件名 2、下载mysql 官网地址:https://downloads.mysql.com/archives/community/ 3、上传解压 4、安装 报错:error: Failed dependencies: net-tools is needed by mysql-community-server-5.7.37-1.el7.x86_64 解决: 5、检查安装 6、开启mysql服务 7、登陆mysql 第一次启动mysq

    2024年02月10日
    浏览(51)
  • MySQL三种安装方法(yum安装、编译安装、二进制安装)

    切记:一定要关闭防火墙和selinux!!! 服务器配置:2C4G即可,一台 mysql的官方网站:www.mysql.com 中文官网:https://www.mysql.com/cn/ 1、下载mysql的yum源 2、安装mysql的yum仓库 3、配置yum源 4、安装数据库 5、查找密码 6、修改密码 两种方式: 第一种:登录数据库后操作 第二种:免入

    2024年02月07日
    浏览(53)
  • 二进制方式安装MySQL并备份数据库

    ①代码 ②结果   ①代码 ②结果 

    2024年02月22日
    浏览(54)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包