首页 > 数据库 >ubuntu 24.04 部署 mysql 8.4.3 LTS

ubuntu 24.04 部署 mysql 8.4.3 LTS

时间:2024-11-01 15:21:35浏览次数:1  
标签:LTS 8.4 24.04 apps local mysqld usr mysql data

安装依赖

apt -y install libaio1t64
ln -sv /usr/lib/x86_64-linux-gnu/libaio.so.1t64.0.2 /usr/lib/x86_64-linux-gnu/libaio.so.1

创建用户

groupadd -g 28 -o -r mysql && useradd -M -N -g mysql -o -r -d /data/mysql -s /bin/false -c "MySQL Server" -u 28  mysql

下载 mysql

wget  https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.4.3-linux-glibc2.28-x86_64.tar.xz

解压 mysql

tar xvf mysql-8.4.3-linux-glibc2.28-x86_64.tar.xz -C /usr/local/
ln -sv /usr/local/mysql-8.4.3-linux-glibc2.28-x86_64 /usr/local/mysql

创建目录

mkdir -pv /data/apps/mysql/{data,logs,tmp,mysql-files} && chown -R mysql:mysql /data/apps/mysql && chmod 750 /data/apps/mysql/mysql-files && chmod 750 /data/apps/mysql/data

创建配置文件

touch /data/apps/mysql/my.cnf && chown root:root /data/apps/mysql/my.cnf && chmod 644 /data/apps/mysql/my.cnf
[mysqld]
datadir=/data/apps/mysql/data
socket=/tmp/mysql.sock
port=3306
log-error=/data/apps/mysql/logs/localhost.localdomain.err
user=mysql
secure_file_priv=/data/apps/mysql/mysql-files
local_infile=OFF

初始化 mysql

/usr/local/mysql/bin/mysqld --defaults-file=/data/apps/mysql/my.cnf   --initialize
2024-11-01T15:15:49.899267+08:00 0 [System] [MY-015017] [Server] MySQL Server Initialization - start.
2024-11-01T15:15:49.901523+08:00 0 [System] [MY-013169] [Server] /usr/local/mysql/bin/mysqld (mysqld 8.4.3) initializing of server in progress as process 2843
2024-11-01T15:15:49.910424+08:00 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2024-11-01T15:15:50.190221+08:00 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2024-11-01T15:15:51.836977+08:00 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: Qmxm(vpiy03!
2024-11-01T15:15:53.897621+08:00 0 [System] [MY-015018] [Server] MySQL Server Initialization - end.

mysqld.service

cat > /lib/systemd/system/mysqld.service << EOF
[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

# Have mysqld write its state to the systemd notify socket
Type=notify

# Disable service start and stop timeout logic of systemd for mysqld service.
TimeoutSec=0

PIDFile=/data/apps/mysql/data/mysqld.pid

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

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

# Sets open_files_limit
LimitNOFILE = 10000

Restart=on-failure

RestartPreventExitStatus=1

# Set environment variable MYSQLD_PARENT_PID. This is required for restart.
Environment=MYSQLD_PARENT_PID=1

PrivateTmp=false

EOF

启用 mysql

systemctl enable mysqld --now
Created symlink /etc/systemd/system/multi-user.target.wants/mysqld.service → /usr/lib/systemd/system/mysqld.service.

安全设置

/usr/local/mysql/bin/mysql_secure_installation -S /data/apps/mysql/mysql.sock

登录验证

/usr/local/mysql/bin/mysql -S /data/apps/mysql/mysql.sock -uroot -p

修改 root 密码

ALTER USER 'root'@'localhost' IDENTIFIED BY 'password';

参考文档

https://dev.mysql.com/doc/mysql-secure-deployment-guide/8.0/en/secure-deployment-install.html

标签:LTS,8.4,24.04,apps,local,mysqld,usr,mysql,data
From: https://www.cnblogs.com/wangguishe/p/18519735

相关文章

  • 【昌哥IT课堂】MySQL8.4.0新特性:FLUSH_PRIVILEGES动态权限细化与隔离[译]
    介绍MySQL支持RELOAD权限。现在,想象一个数据库用户被授予了RELOAD权限,这允许该用户在系统上执行FLUSHPRIVILEGES语句。假设该用户意外地执行了另一个强大的语句,比如RESET或FLUSHTABLES。这可能会导致一些问题,对吧?考虑一个数据库管理员创建一个用户,目的是允许该用户仅......
  • Go入门指南-8.4map 类型的切片
    假设我们想获取一个map类型的切片,我们必须使用两次make()函数,第一次分配切片,第二次分配切片中每个map元素(参见下面的例子8.4)。示例8.4maps_forrange2.go:packagemainimport"fmt"funcmain(){ //VersionA: items:=make([]map[int]int,5) fori:=ra......
  • 强大的文本编辑器Notepad++8.4.6 最新版
          Notepad++最新版是一款多功能的代码编辑工具。Notepad++官方版支持27种编程语言,涵盖C、C++、Java、C#,、XML、HTML,、PHP、python等等,能够帮助程序员提高编辑效率。Notepad++软件支持python与sql代码高亮功能,并且免费开源,能够完美地取代微软视窗的记事本功......
  • 给虚拟机挂载一块硬盘(以ubuntu24.04为例)
    一、新增、分区、格式化新盘1、首先在虚拟机中增加一块新硬盘(500G)例如:Vmware、Exsi软件,增加完成后,查看一下:root@ubuntu:~#lsblk-fNAMEFSTYPEFSVERLABELUUIDFSAVAILFSUSE%MOUNTPOINTSsda......
  • ubuntu24.04安装完以后发现硬盘空间少一半
    1、查看现在硬盘情况root@ubuntu:~#df-hFilesystemSizeUsedAvailUse%Mountedontmpfs1.6G1.1M1.6G1%/runefivarfs256K64K188K26%/sys/firmware/efi/efivars/dev......
  • Ubuntu 22.04 LTS 在线/离线安装 Docker
    Docker安装方式准备环境root@ubuntu2204:~#hostnamectlStatichostname:ubuntu2204Iconname:computer-vmChassis:vmMachineID:06204406df2343f89f6ba6550a356854BootID:3142ea12a9e64adbab7b8939935e7698Virtualization:vmw......
  • windows安装MySQL8.4.3LTS
    windows安装MySQL8.4.3LTS第一步:下载压缩文件https://dev.mysql.com/downloads/mysql/第二步:解压压缩包以及编写配置my.ini配置[mysqld]#skip_grant_tables#设置3306端口port=3306#设置mysql的安装目录basedir=D:\\Software\\mysql-8.4.3-winx64#设置mysql数据库......
  • Windows 11 version 24H2 & LTSC 2024 中文版、英文版 (x64、ARM64) 下载 (updated Oc
    Windows11version24H2&LTSC2024中文版、英文版(x64、ARM64)下载(updatedOct2024)Windows11,version24H2,企业版arm64x64请访问原文链接:https://sysin.org/blog/windows-11/查看最新版。原创作品,转载请保留出处。作者主页:sysin.org全新推出Windows11全新......
  • 【2024潇湘夜雨】WIN 11_IoT_Ent_LTSC_2024_24H2.26100.2161软件选装纯净特别版10.26
    【系统简介】=============================================================1.本次更新母盘来自WIN11_IoT_Ent_LTSC_2024_24H2.26100.2161.进桌面后稍等片刻,等待后续部分优化完成。2.全程离线精简、无人值守调用优化处理制作。部分优化适配系统可能要重启几次,即使显示适配失败也......
  • linux 一键部署mysql 8.4.2 绿色版
    亲测有效vimdeploy_mysql.sh#!/bin/bash#mysql安装目录是${wget_path}/${mysql_dir}#修改mysql的登录密码updatePassword="sykj@2024"wget_path="/data"mysql_dir="mysql"#.tar.xz文件mysql_dowmload_path="https://downloads.mysql.com/......