99%的焦虑都来自于虚度时间和没有好好做事,所以唯一的解决办法就是行动起来,认真做完事情,战胜焦虑,战胜那些心里空荡荡的时刻,而不是选择逃避。不要站在原地想象困难,行动永远是改变现状的最佳方式
写在前面
博文内容为 openEuler 24.03 (LTS)
版本 mysql 8.4
二进制安装教程
理解不足小伙伴帮忙指正 :),生活加油
99%的焦虑都来自于虚度时间和没有好好做事,所以唯一的解决办法就是行动起来,认真做完事情,战胜焦虑,战胜那些心里空荡荡的时刻,而不是选择逃避。不要站在原地想象困难,行动永远是改变现状的最佳方式
使用的环境
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 ┌──[root@liruilongs.github.io]-[~] └─$hostnamectl Static hostname: liruilongs.github.io Icon name: computer-vm Chassis: vm 🖴 Machine ID: d8b7006e0b5246d3940d0da0b5e4d792 Boot ID: 6bffb39c9d5845378c20ba3553a54b02 Virtualization: vmware Operating System: openEuler 24.03 (LTS) Kernel: Linux 6.6.0-44.0.0.50.oe2403.x86_64 Architecture: x86-64 Hardware Vendor: VMware, Inc. Hardware Model: VMware Virtual Platform Firmware Version: 6.00 Firmware Date: Wed 2020-07-22 Firmware Age: 4y 2month 2w 1d
二进制包安装 MySQL 是比较常用的一种方式,主要分为六个步骤:
获取二进制安装包。
创建运行 MySQL
的用户
,规划数据目录,
准备 my.cnf
参数文件
初始化数据库,启动数据库服务。
设置数据库初始密码。
获取二进制安装包。 官网地址: https://dev.mysql.com/downloads/mysql/
使用二进制安装时,操作系统选择Linux - Generic
,操作系统版本要根据系统的 glibc
版本来选择,确定 glibc
的版本
1 2 3 4 5 6 7 ┌──[root@liruilongs.github.io]-[~] └─$ldd --version ldd (GNU libc) 2.38 Copyright (C) 2023 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Written by Roland McGrath and Ulrich Drepper.
确定架构
1 2 3 ┌──[root@liruilongs.github.io]-[~] └─$arch x86_64
安装包下载完成后使用 md5sum
工具检查文件校验码是否和官网上提供的一致。
1 2 3 4 5 6 7 8 9 10 11 12 ┌──[root@liruilongs.github.io]-[~] └─$wget https://cdn.mysql.com//Downloads/MySQL-8.4/mysql-8.4.3-linux-glibc2.28-x86_64.tar.xz --2024-10-06 10:00:43-- https://cdn.mysql.com//Downloads/MySQL-8.4/mysql-8.4.3-linux-glibc2.28-x86_64.tar.xz 正在解析主机 cdn.mysql.com (cdn.mysql.com)... 23.37.58.58, 2600:1406:3400:79a::1d68, 2600:1406:3400:799::1d68 正在连接 cdn.mysql.com (cdn.mysql.com)|23.37.58.58|:443... 已连接。 已发出 HTTP 请求,正在等待回应... 200 OK 长度:908299408 (866M) [text/plain] 正在保存至: “mysql-8.4.3-linux-glibc2.28-x86_64.tar.xz” mysql-8.4.3-linux-glibc2.28- 100%[==============================================>] 866.22M 6.65MB/s 用时 3m 31s 2024-10-06 10:04:15 (4.10 MB/s) - 已保存 “mysql-8.4.3-linux-glibc2.28-x86_64.tar.xz” [908299408/908299408])
计算 md5
1 2 3 4 5 ┌──[root@liruilongs.github.io]-[~] └─$md5sum mysql-8.4.3-linux-glibc2.28-x86_64.tar.xz 0d7f2af1ac4fa3afca87608a3dec5596 mysql-8.4.3-linux-glibc2.28-x86_64.tar.xz ┌──[root@liruilongs.github.io]-[~] └─$
解压文件
,移动解压后的文件夹到/opt/
目录,创建符号链接
1 2 3 4 5 6 7 8 ┌──[root@liruilongs.github.io]-[~] └─$tar xvf mysql-8.4.3-linux-glibc2.28-x86_64.tar.xz ┌──[root@liruilongs.github.io]-[~] └─$mv mysql-8.4.3-linux-glibc2.28-x86_64 /opt/ ┌──[root@liruilongs.github.io]-[~] └─$ln -s /opt/mysql-8.4.3-linux-glibc2.28-x86_64/ /opt/mysql84 ┌──[root@liruilongs.github.io]-[~] └─$
这里简单介绍下可执行文件
1 2 3 4 5 6 7 8 9 10 11 ┌──[root@liruilongs.github.io]-[~] └─$cd /opt/mysql84 ┌──[root@liruilongs.github.io]-[/opt/mysql84] └─$cd bin/;ls ibd2sdi myisampack mysqlcheck mysqld_multi mysql_migrate_keyring perror innochecksum my_print_defaults mysql_config mysqld_safe mysql_secure_installation myisamchk mysql mysql_config_editor mysqldump mysqlshow myisam_ftdump mysqladmin mysqld mysqldumpslow mysqlslap myisamlog mysqlbinlog mysqld-debug mysqlimport mysql_tzinfo_to_sql ┌──[root@liruilongs.github.io]-[/opt/mysql84/bin] └─$
在/opt/mysql84/bin
目录下为MySQL相关的可执行文件,包括但不限于:
mysql
: MySQL客户端程序,用于连接和管理MySQL服务器。
mysqldump
: 用于备份MySQL数据库的工具。
mysqladmin
: 用于执行管理操作的MySQL客户端工具。
mysqld
: MySQL服务器的主程序。
mysql_config
: 用于获取MySQL编译配置信息的工具。
mysql_secure_installation
: 用于增强新安装MySQL服务器安全性的脚本。
创建Mysql 用户,规划数据目录 创建组以及对应的用户
1 2 3 4 ┌──[root@liruilongs.github.io]-[/opt/mysql84/support-files] └─$groupadd mysql84 ┌──[root@liruilongs.github.io]-[/opt/mysql84/support-files] └─$useradd mysql84 -g mysql84
创建MySQL
数据目录结构,重新修改权限
1 2 3 4 5 6 ┌──[root@liruilongs.github.io]-[/] └─$mkdir -p /data/mysql3306/{data,log ,binlog,relaylog,run,tmp} ┌──[root@liruilongs.github.io]-[/] └─$ chown -R mysql84:mysql84 /data/mysql3306 ┌──[root@liruilongs.github.io]-[/] └─$
准备 my.cnf
参数文件 准备 my.cnf
参数文件,注意这里目录要修改为上面创建的目录
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 ┌──[root@liruilongs.github.io]-[/data/mysql3306] └─$cat my.cnf [mysql] socket=/data/mysql3306/run/mysql.sock [mysqld] port=3306 mysqlx_port=33060 basedir=/opt/mysql84 lc_messages_dir=/opt/mysql84/share datadir=/data/mysql3306/data tmpdir=/data/mysql3306/tmp log-error=/data/mysql3306/log /alert.log slow_query_log_file=/data/mysql3306/log /slow.log general_log_file=/data/mysql3306/log /general.log socket=/data/mysql3306/run/mysql.sock innodb_data_file_path=ibdata1:128M:autoextend innodb_buffer_pool_size=2G
初始化数据库 使用 mysqld 初始化数据库,第一个参数必须是 defaults-file
,指向上一步准备好的 my.cnf
配置文件,第二个参数是 initialize
,指示 mysqld
进行初始化操作。
1 2 ┌──[root@liruilongs.github.io]-[/data] └─$/opt/mysql84/bin/mysqld --defaults-file=/data/mysql3306/my.cnf --initialize
如果初始化没有成功,需要到错误日志中查看相关的报错信息,进行相应的处理。
错误日志的路径由配置文件中的参数 log-error
指定。初始化成功后,可以看到错误日志的最后一行输出的 mysql root
账号的临时密码
,我们要用这个密码来登录数据库。
1 2 3 4 5 6 7 8 9 ┌──[root@liruilongs.github.io]-[/data/mysql3306/data] └─$tail -10 /data/mysql3306/log /alert.log ..................... 2024-10-08T14:45:09.175721Z 0 [System] [MY-015017] [Server] MySQL Server Initialization - start. 2024-10-08T14:45:09.177222Z 0 [System] [MY-013169] [Server] /opt/mysql84/bin/mysqld (mysqld 8.4.3) initializing of server in progress as process 66359 2024-10-08T14:45:09.206262Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started. 2024-10-08T14:45:09.853587Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended. 2024-10-08T14:45:12.761123Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: hde9_0vealB6 2024-10-08T14:45:14.733882Z 0 [System] [MY-015018] [Server] MySQL Server Initialization - end.
初始化使用的是 root
用户,所以还需要在修改一次权限
1 2 ┌──[root@liruilongs.github.io]-[/data/mysql3306/data] └─$chown -R mysql84:mysql84 /data/mysql3306/
启动数据库服务 这里使用 mysqld_safe
脚本来启动 MySQL
,使用 defaults-file
指定参数文件的路径。
1 2 3 4 5 6 7 8 9 ┌──[root@liruilongs.github.io]-[~] └─$/opt/mysql84/bin/mysqld_safe --defaults-file=/data/mysql3306/my.cnf & [1] 64154 ┌──[root@liruilongs.github.io]-[~] └─$2024 -10-08T14:10:51.409242Z mysqld_safe Logging to '/data/mysql3306/log/alert.log' . 2024-10-08T14:10:51.499097Z mysqld_safe Starting mysqld daemon with databases from /data/mysql3306/data 2024-10-08T14:10:53.183109Z mysqld_safe mysqld from pid file /data/mysql3306/data/liruilongs.github.io.pid ended [1]+ 已完成 /opt/mysql84/bin/mysqld_safe --defaults-file=/data/mysql3306/my.cnf
这里出现了问题,正常应该不会是已完成才对,可以看到也没有明显的报错信息
这里首先排查一下是不是存储资源的问问
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ┌──[root@liruilongs.github.io]-[/data/mysql3306/data] └─$lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS sda 8:0 0 14G 0 disk ├─sda1 8:1 0 1M 0 part ├─sda2 8:2 0 1G 0 part /boot └─sda3 8:3 0 13G 0 part ├─openeuler-root 253:0 0 11.6G 0 lvm / └─openeuler-swap 253:1 0 1.4G 0 lvm [SWAP] sr0 11:0 1 3.9G 0 rom ┌──[root@liruilongs.github.io]-[/data/mysql3306/data] └─$df -h 文件系统 大小 已用 可用 已用% 挂载点 /dev/mapper/openeuler-root 12G 11G 0 100% / devtmpfs 4.0M 0 4.0M 0% /dev tmpfs 5.7G 0 5.7G 0% /dev/shm tmpfs 4.0M 0 4.0M 0% /sys/fs/cgroup tmpfs 2.3G 29M 2.3G 2% /run tmpfs 5.7G 40K 5.7G 1% /tmp /dev/sda2 974M 260M 647M 29% /boot
存储确实不够了,但是不确定是不是这里的问题,这里为了实验,我们先把交换分区删了。生产中操作需要谨慎
1 2 3 4 ┌──[root@liruilongs.github.io]-[/data/mysql3306/data] └─$lvscan ACTIVE '/dev/openeuler/swap' [1.40 GiB] inherit ACTIVE '/dev/openeuler/root' [11.59 GiB] inherit
关闭交换分区
1 2 ┌──[root@liruilongs.github.io]-[/data/mysql3306/data] └─$sudo swapoff /dev/mapper/openeuler-swap
删除 openeuler-swap
对应的逻辑卷
1 2 3 4 ┌──[root@liruilongs.github.io]-[/data/mysql3306/data] └─$sudo lvremove /dev/mapper/openeuler-swap Do you really want to remove active logical volume openeuler/swap? [y/n]: y Logical volume "swap" successfully removed.
逻辑卷 openeuler-root
扩展到剩余的全部可用空间
1 2 3 4 ┌──[root@liruilongs.github.io]-[/data/mysql3306/data] └─$sudo lvextend -l +100%FREE /dev/mapper/openeuler-root Size of logical volume openeuler/root changed from 11.59 GiB (2968 extents) to <13.00 GiB (3327 extents). Logical volume openeuler/root successfully resized.
查看之前的文件系统格式
1 2 3 ┌──[root@liruilongs.github.io]-[/data/mysql3306/data] └─$blkid /dev/mapper/openeuler-root /dev/mapper/openeuler-root: UUID="961a4d38-e792-4742-9f12-17c135f8e405" BLOCK_SIZE="4096" TYPE="ext4"
重新格式化文件系统
1 2 3 4 5 6 7 ┌──[root@liruilongs.github.io]-[/data/mysql3306/data] └─$sudo resize2fs /dev/mapper/openeuler-root resize2fs 1.47.0 (5-Feb-2023) /dev/mapper/openeuler-root 上的文件系统已被挂载于 /;需要进行在线调整大小 old_desc_blocks = 2, new_desc_blocks = 2 /dev/mapper/openeuler-root 上的文件系统大小已经调整为 3406848 个块(每块 4k)。
再次查看文件系统
1 2 3 4 5 6 7 8 9 10 11 12 ┌──[root@liruilongs.github.io]-[/data/mysql3306/data] └─$df -h 文件系统 大小 已用 可用 已用% 挂载点 /dev/mapper/openeuler-root 13G 11G 1.3G 91% / devtmpfs 4.0M 0 4.0M 0% /dev tmpfs 5.7G 0 5.7G 0% /dev/shm tmpfs 4.0M 0 4.0M 0% /sys/fs/cgroup tmpfs 2.3G 29M 2.3G 2% /run tmpfs 5.7G 40K 5.7G 1% /tmp /dev/sda2 974M 260M 647M 29% /boot ┌──[root@liruilongs.github.io]-[/data/mysql3306/data] └─$
再次尝试启动,查看日志信息
1 2 3 4 5 6 7 8 9 ┌──[root@liruilongs.github.io]-[~] └─$/opt/mysql84/bin/mysqld_safe --defaults-file=/data/mysql3306/my.cnf & [1] 66433 ┌──[root@liruilongs.github.io]-[~] └─$2024 -10-08T14:46:48.777485Z mysqld_safe Logging to '/data/mysql3306/log/alert.log' . 2024-10-08T14:46:48.813729Z mysqld_safe Starting mysqld daemon with databases from /data/mysql3306/data 2024-10-08T14:46:49.146727Z mysqld_safe mysqld from pid file /data/mysql3306/data/liruilongs.github.io.pid ended [1]+ 已完成 /opt/mysql84/bin/mysqld_safe --defaults-file=/data/mysql3306/my.cnf
还是没有启动成功,排除配置文件的问题,这里使用默认的配置启动
1 2 3 4 5 6 7 8 9 10 11 12 ┌──[root@liruilongs.github.io]-[~] └─$/opt/mysql84/bin/mysqld 2024-10-08T14:48:24.843155Z 0 [System] [MY-015015] [Server] MySQL Server - start. 2024-10-08T14:48:25.014506Z 0 [System] [MY-010116] [Server] /opt/mysql84/bin/mysqld (mysqld 8.4.3) starting as process 66654 2024-10-08T14:48:25.016234Z 0 [Warning] [MY-010091] [Server] Can't create test file /opt/mysql-8.4.3-linux-glibc2.28-x86_64/data/mysqld_tmp_file_case_insensitive_test.lower-test 2024-10-08T14:48:25.016348Z 0 [Warning] [MY-010159] [Server] Setting lower_case_table_names=2 because file system for /opt/mysql-8.4.3-linux-glibc2.28-x86_64/data/ is case insensitive 2024-10-08T14:48:25.016439Z 0 [ERROR] [MY-010123] [Server] Fatal error: Please read "Security" section of the manual to find out how to run mysqld as root! 2024-10-08T14:48:25.016492Z 0 [ERROR] [MY-010119] [Server] Aborting 2024-10-08T14:48:25.016886Z 0 [System] [MY-010910] [Server] /opt/mysql84/bin/mysqld: Shutdown complete (mysqld 8.4.3) MySQL Community Server - GPL. 2024-10-08T14:48:25.016889Z 0 [System] [MY-015016] [Server] MySQL Server - end. ┌──[root@liruilongs.github.io]-[~] └─$
可以日志的报错信息了,安全原因,不建议使用 root 用户,严重错误:请阅读手册的”安全”部分,了解如何以root身份运行mysqld!
1 2 3 ........ 2024-10-08T14:48:25.016439Z 0 [ERROR] [MY-010123] [Server] Fatal error: Please read "Security" section of the manual to find out how to run mysqld as root! 2024-10-08T14:48:25.016492Z 0 [ERROR] [MY-010119] [Server] Aborting
权限的问题,这里重新修改下目录
1 2 ┌──[root@liruilongs.github.io]-[~] └─$chown -R mysql84:mysql84 /data/mysql3306/
使用之前创建过的用户 mysql84
执行启动
1 2 3 4 5 6 ┌──[root@liruilongs.github.io]-[/data/mysql3306] └─$sudo -u mysql84 /opt/mysql84/bin/mysqld_safe --defaults-file=/data/mysql3306/my.cnf & [1] 68476 ┌──[root@liruilongs.github.io]-[/data/mysql3306] └─$2024 -10-08T15:20:02.726002Z mysqld_safe Logging to '/data/mysql3306/log/alert.log' . 2024-10-08T15:20:02.790745Z mysqld_safe Starting mysqld daemon with databases from /data/mysql3306/data
启动成功,查看对应的 mysqld
进程
1 2 3 4 ┌──[root@liruilongs.github.io]-[/opt/mysql84/bin] └─$pgrep mysqld 68479 68701
可以看到这里有两个进程,一个是 mysql
的还有一个是 mysqld_safe
,查看日志信息
1 2 3 4 5 6 7 8 9 10 11 12 2024-10-08T15:20:02.726002Z mysqld_safe Logging to '/data/mysql3306/log/alert.log' . 2024-10-08T15:20:02.790745Z mysqld_safe Starting mysqld daemon with databases from /data/mysql3306/data 2024-10-08T15:20:02.828832Z 0 [System] [MY-015015] [Server] MySQL Server - start. 2024-10-08T15:20:03.063329Z 0 [System] [MY-010116] [Server] /opt/mysql84/bin/mysqld (mysqld 8.4.3) starting as process 68701 2024-10-08T15:20:03.097738Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started. 2024-10-08T15:20:03.778021Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended. 2024-10-08T15:20:03.850650Z 0 [System] [MY-010229] [Server] Starting XA crash recovery... 2024-10-08T15:20:03.853933Z 0 [System] [MY-010232] [Server] XA crash recovery finished. 2024-10-08T15:20:03.934348Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed. 2024-10-08T15:20:03.934374Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel. 2024-10-08T15:20:03.951215Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '::' port: 33060, socket: /tmp/mysqlx.sock 2024-10-08T15:20:03.951242Z 0 [System] [MY-010931] [Server] /opt/mysql84/bin/mysqld: ready for connections. Version: '8.4.3' socket: '/data/mysql3306/run/mysql.sock' port: 3306 MySQL Community Server - GPL.
根据进程信息查看启动命令,可以看到执行启动命令
1 2 3 4 5 6 7 8 ┌──[root@liruilongs.github.io]-[/opt/mysql84/bin] └─$cat /proc/68701/cmdline && echo "" /opt/mysql84/bin/mysqld--defaults-file=/data/mysql3306/my.cnf--basedir=/opt/mysql84--datadir=/data/mysql3306/data--plugin-dir=/opt/mysql84/lib/plugin--log-error=/data/mysql3306/log /alert.log--pid-file=liruilongs.github.io.pid--socket=/data/mysql3306/run/mysql.sock--port=3306 ┌──[root@liruilongs.github.io]-[/opt/mysql84/bin] └─$cat /proc/68479/cmdline && echo "" /bin/sh/opt/mysql84/bin/mysqld_safe--defaults-file=/data/mysql3306/my.cnf ┌──[root@liruilongs.github.io]-[/opt/mysql84/bin] └─$
68701
为 mysql
的进程, 68479
为 mysqld_safe
进程,测试我们可以发现,如果
kill掉
mysql 的进程,
mysqld_safe` 会重新拉起进程。
1 2 3 4 5 6 7 8 9 ┌──[root@liruilongs.github.io]-[/opt/mysql84/bin] └─$kill -9 68701 ┌──[root@liruilongs.github.io]-[/opt/mysql84/bin] └─$pgrep mysqld 68479 68805 ┌──[root@liruilongs.github.io]-[/opt/mysql84/bin] └─$cat /proc/68805/cmdline && echo "" /opt/mysql84/bin/mysqld--defaults-file=/data/mysql3306/my.cnf--basedir=/opt/mysql84--datadir=/data/mysql3306/data--plugin-dir=/opt/mysql84/lib/plugin--log-error=/data/mysql3306/log /alert.log--pid-file=liruilongs.github.io.pid--socket=/data/mysql3306/run/mysql.sock--port=3306
如果 kill
掉 mysqld_safe
, 在 kill 掉 mysqld
,mysql
就不会被拉起来了.
1 2 3 4 5 6 7 8 9 ┌──[root@liruilongs.github.io]-[/opt/mysql84/bin] └─$kill -9 68479 ┌──[root@liruilongs.github.io]-[/opt/mysql84/bin] └─$pgrep mysqld 68805 ┌──[root@liruilongs.github.io]-[/opt/mysql84/bin] └─$kill -9 68805 ┌──[root@liruilongs.github.io]-[/opt/mysql84/bin] └─$pgrep mysqld
设置数据库初始密码 使用上面的初始密码登陆
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ┌──[root@liruilongs.github.io]-[/opt/mysql84/bin] └─$echo "export PATH=$PATH :/opt/mysql84/bin/" >> ~/.bashrc ┌──[root@liruilongs.github.io]-[/opt/mysql84/bin] └─$source ~/.bashrc ┌──[root@liruilongs.github.io]-[/opt/mysql84/bin] └─$mysql -uroot -h127.0.0.1 -p'hde9_0vealB6' 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 8 Server version: 8.4.3 Copyright (c) 2000, 2024, 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. mysql>
设置新的密码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 mysql> select now(); ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement. mysql> alter user 'root' @'localhost' identified by 'Liruilong1008' ; Query OK, 0 rows affected (0.01 sec) mysql> select now(); + | now() | + | 2024 -10 -08 23 :43 :48 | + 1 row in set (0.00 sec)mysql>
完整的步骤
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 ┌──[root@liruilongs.github.io]-[~] └─$mv mysql-8.4.3-linux-glibc2.28-x86_64 /opt/ ┌──[root@liruilongs.github.io]-[~] └─$ln -s /opt/mysql-8.4.3-linux-glibc2.28-x86_64/ /opt/mysql84 ┌──[root@liruilongs.github.io]-[~] └─$groupadd mysql84 ┌──[root@liruilongs.github.io]-[~] └─$useradd mysql84 -g mysql84 ┌──[root@liruilongs.github.io]-[~] └─$mkdir -p /data/mysql3306/{data,log ,binlog,relaylog,run,tmp} ┌──[root@liruilongs.github.io]-[~] └─$cd /data/mysql3306/ ┌──[root@liruilongs.github.io]-[/data/mysql3306] └─$vim my.cnf ┌──[root@liruilongs.github.io]-[/data/mysql3306] └─$/opt/mysql84/bin/mysqld --defaults-file=/data/mysql3306/my.cnf --initialize ┌──[root@liruilongs.github.io]-[/data/mysql3306] └─$tail -2 /data/mysql3306/log /alert.log 2024-12-08T08:02:58.428134Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: 9c6<f,sl:-Z* 2024-12-08T08:03:00.331840Z 0 [System] [MY-015018] [Server] MySQL Server Initialization - end. ┌──[root@liruilongs.github.io]-[/data/mysql3306] └─$chown -R mysql84:mysql84 /data/mysql3306 ┌──[root@liruilongs.github.io]-[/data/mysql3306] └─$sudo -u mysql84 /opt/mysql84/bin/mysqld_safe --defaults-file=/data/mysql3306/my.cnf & [1] 2650 ┌──[root@liruilongs.github.io]-[/data/mysql3306] └─$2024 -12-08T08:04:16.831180Z mysqld_safe Logging to '/data/mysql3306/log/alert.log' . 2024-12-08T08:04:16.856024Z mysqld_safe Starting mysqld daemon with databases from /data/mysql3306/data ┌──[root@liruilongs.github.io]-[/data/mysql3306] └─$echo "export PATH=$PATH :/opt/mysql84/bin/" >> ~/.bashrc ┌──[root@liruilongs.github.io]-[/data/mysql3306] └─$source ~/.bashrc ┌──[root@liruilongs.github.io]-[/data/mysql3306] └─$mysql -uroot -h127.0.0.1 -p'9c6<f,sl:-Z*' 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 8 Server version: 8.4.3 Copyright (c) 2000, 2024, 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. mysql> alter user 'root' @'localhost' identified by 'Liruilong1008' ; Query OK, 0 rows affected (0.01 sec) mysql>