Oracle linux 8 二进制安装 MySQL 8.4企业版

使用命令ldd --version ldd 检查,确定MySQL 8二进制包版本

代码语言:javascript代码运行次数:0运行复制
[root@mysql8_3 ~]# ldd --version ldd

安装libaio

代码语言:javascript代码运行次数:0运行复制
[root@mysql8_3 ~]#yum install libaio

安装ncurses-compat-libs

代码语言:javascript代码运行次数:0运行复制
[root@mysql8_3 ~]#yum install ncurses-compat-libs

创建安装目录

代码语言:javascript代码运行次数:0运行复制
[root@mysql8_3 ]#mkdir /u01

创建用户

代码语言:javascript代码运行次数:0运行复制
[root@mysql8_3 ]# useradd -r -g mysql -s /bin/false mysql

进入安装目录

代码语言:javascript代码运行次数:0运行复制
[root@mysql8_3 u01]# cd /u01

解压安装包

代码语言:javascript代码运行次数:0运行复制
[root@mysql8_3 u01]# tar xvf mysql-commercial-8.4.4-linux-glibc2.28-x86_64.tar.xz

修改安装目录名字

代码语言:javascript代码运行次数:0运行复制
[root@mysql8_3 u01]# mv mysql-commercial-8.4.4-linux-glibc2.28-x86_64 mysql3308

创建程序目录

代码语言:javascript代码运行次数:0运行复制
[root@mysql8_3 mysql3308]# mkdir base

把解压包的文件及文件夹移动到base目录

代码语言:javascript代码运行次数:0运行复制
[root@mysql8_3 mysql3308]# mv * base/

创建数据目录

代码语言:javascript代码运行次数:0运行复制
[root@mysql8_3 mysql3308]# mkdir data

给整个数据库目录赋予mysql用户及组

代码语言:javascript代码运行次数:0运行复制
[root@mysql8_3 mysql3308]# cd ..[root@mysql8_3 u01]# chown -R mysql.mysql mysql3308

对数据库进行初始化,记住初始root密码

代码语言:javascript代码运行次数:0运行复制
[root@mysql8_3 mysql3308]# base/bin/mysqld --initialize --datadir=/u01/mysql3308/data/ --user=mysql2025-04-09T06:10:07.862792Z 0 [System] [MY-015017] [Server] MySQL Server Initialization - start.2025-04-09T06:10:07.866074Z 0 [System] [MY-013169] [Server] /u01/mysql-commercial-8.4.4-linux-glibc2.28-x86_64/base/bin/mysqld (mysqld 8.4.4-commercial) initializing of server in progress as process 118982025-04-09T06:10:08.040918Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.2025-04-09T06:10:11.812516Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.2025-04-09T06:10:25.552364Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: fc9%Xt<E5eF/2025-04-09T06:10:38.228926Z 0 [System] [MY-015018] [Server] MySQL Server Initialization - end.

测试数据库启动

代码语言:javascript代码运行次数:0运行复制
[root@mysql8_3 mysql3308]# ./base/bin/mysqld_safe --datadir=/u01/mysql3308/data/ --user=mysql &[1] 12586[root@mysql8_3 mysql3308]# 2025-04-09T06:15:10.255451Z mysqld_safe Logging to '/u01/mysql3308/data/mysql8_3.52.err'.2025-04-09T06:15:10.330480Z mysqld_safe Starting mysqld daemon with databases from /u01/mysql3308/data

查看启动端口

代码语言:javascript代码运行次数:0运行复制
[root@mysql8_3 mysql3308]# netstat -antupl

修改root 密码

代码语言:javascript代码运行次数:0运行复制
[root@mysql8_3 mysql3308]# ./base/bin/mysql -uroot -pEnter password:Welcome to the MySQL monitor.  Commands end with ; or \g.Your MySQL connection id is 8Server version: 8.4.4-commercialCopyright (c) 2000, 2025, Oracle and/or its affiliates.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql>mysql> set password='123456';

测试修改后root密码登陆

代码语言:javascript代码运行次数:0运行复制
[root@mysql8_3 mysql3308]# ./base/bin/mysql -uroot -p123456mysql: [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 10Server version: 8.4.4-commercial MySQL Enterprise Server - CommercialCopyright (c) 2000, 2025, Oracle and/or its affiliates.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql> exitBye

添加mysql启动脚本

代码语言:javascript代码运行次数:0运行复制
[root@mysql8_3 mysql3308]# cp base/support-files/mysql.server /etc/init.d/mysql.server

修改mysql启动脚本,并添加程序目录和数据目录

代码语言:javascript代码运行次数:0运行复制
[root@mysql8_3 mysql3308]# vim /etc/init.d/mysql.server# If you change base dir, you must also change datadir. These may get# overwritten by settings in the MySQL configuration files.basedir=/u01/mysql3308/basedatadir=/u01/mysql3308/data

测试mysql启动脚本

代码语言:javascript代码运行次数:0运行复制
[root@mysql8_3 mysql3308]# /etc/init.d/mysql.server startStarting MySQL.... SUCCESS![root@mysql8_3 mysql3308]# netstat -antupl

添加mysql环境变量

代码语言:javascript代码运行次数:0运行复制
[root@mysql8_3 mysql3308]# echo "export PATH=$PATH:/u01/mysql3308/base/bin" >> /etc/profile[root@mysql8_3 mysql3308]# source /etc/profile[root@mysql8_3 mysql3308]# mysql -uroot -p123456mysql: [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 8Server version: 8.4.4-commercial MySQL Enterprise Server - CommercialCopyright (c) 2000, 2025, Oracle and/or its affiliates.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql>

添加mysql配置文件

代码语言:javascript代码运行次数:0运行复制
[root@mysql8_3 mysql3308]# vim myf[mysqld]user=mysqlport=3308mysqlx_port=33080basedir=/u01/mysql3308/basedatadir=/u01/mysql3308/datasocket = /u01/mysql3308/data/mysql.sockpid-file = /u01/mysql3308/data/mysql.pidlog_error = /u01/mysql3308/data/mysql-error.loglog_timestamps=SYSTEMcharacter_set_server=utf8mb4skip_name_resolve=1binlog_format=rowlog-bin = /u01/mysql3308/data/binlogserver-id = 03533308skip_slave_start=1open_files_limit=65535innodb_buffer_pool_size=3Ginnodb_log_buffer_size=16Minnodb_log_file_size=256Msort_buffer_size = 6M

修改myf文件属主

代码语言:javascript代码运行次数:0运行复制
[root@mysql8_3 mysql3308]# chown mysql:mysql myf

增加mysql系统自启动脚本

代码语言:javascript代码运行次数:0运行复制
[root@mysql8_3 mysql3308]#  vim /usr/lib/systemd/system/mysqld83308.service# This service is actually a systemd target,# but we are using a service since targets cannot be reloaded.[Unit]Description=MySQL ServerDocumentation=mysqld.serviceAfter=network.targetAfter=syslog.target[Install]WantedBy=multi-user.target[Service]User=mysqlGroup=mysqlExecStart=/u01/mysql3308/base/bin/mysqld --defaults-file=/u01/mysql3308/myfLimitNOFILE = 5000

测试mysql自启动脚本

代码语言:javascript代码运行次数:0运行复制
[root@mysql8_3 mysql3308]# systemctl restart mysqld83308.service[root@mysql8_3 mysql3308]# netstat -antupl

测试mysql自启动脚本后,root登陆,由于改了sock的路径不是默认的/tmp/mysql.sock,所以登录root需要手动指定sock路径

代码语言:javascript代码运行次数:0运行复制
[root@mysql8_3 mysql3308]# mysql -uroot -p123456 -S /u01/mysql3308/data/mysql.sockmysql: [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 8Server version: 8.4.4-commercial MySQL Enterprise Server - CommercialCopyright (c) 2000, 2025, Oracle and/or its affiliates.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql>
图片