MySQL 8 二进制文件安装 概述mysql官方 https://www.mysql.com/社区版下载地址 https://dev.mysql.com/downloads/检查是否安装mariadb如果有先卸载rpm-qa|grepmariadb[rootCentos7-2243 config]# rpm -qa|grep mariadbmariadb-libs-5.5.68-1.el7.x86_64[rootCentos7-2243 config]# yum remove -y mariadb-libs-5.5.68https://dev.mysql.com/downloads/mysql/tar-xvfmysql-8.4.2-linux-glibc2.17-x86_64.tar.xzmvmysql-8.4.2-linux-glibc2.17-x86_64 /usr/local/mysql8.4.2useradd-s/sbin/nologin mysql安装依赖yuminstalllibaio-devel libaio-develcd/usr/local/mysql8.4.2mkdir/public/mysqldb/datamkdir/public/mysqldb/logsmkdir/public/mysqldb/tmpmkdir/etc/mysql增加环境变量vim/etc/profileexportMYSQL_HOME/usr/local/mysql8.4.2/PATH$MYSQL_HOME/bin:$PATHexportPATHsource/etc/profile简单配置my_3306.cnfvim/etc/mysql/my_3306.cnf# For advice on how to change settings please see# http://dev.mysql.com/doc/refman/8.2/en/server-configuration-defaults.html[mysqld]## Remove leading # and set to the amount of RAM for the most important data# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.# innodb_buffer_pool_size 128M## Remove the leading # to disable binary logging# Binary logging captures changes between backups and is enabled by# default. Its default setting is log_binbinlog# disable_log_bin## Remove leading # to set options mainly useful for reporting servers.# The server defaults are faster for transactions and fast SELECTs.# Adjust sizes as needed, experiment to find the optimal values.# join_buffer_size 128M# sort_buffer_size 2M# read_rnd_buffer_size 2M## Remove leading # to revert to previous value for default_authentication_plugin,# this will increase compatibility with older clients. For background, see:# https://dev.mysql.com/doc/refman/8.2/en/server-system-variables.html#sysvar_default_authentication_plugin# default-authentication-pluginmysql_native_password# 设置3306端口port3306socket/public/mysqldb/tmp/mysql.sockmysqlx_socket/public/mysqldb/tmp/mysqlx.sock pid-file/public/mysqldb/tmp/mysqld.pid# 设置mysql的安装目录basedir/usr/local/mysql8.4.2# 设置mysql数据库的数据的存放目录datadir/public/mysqldb/data# 允许最大连接数max_connections10000# 允许连接失败的次数。这是为了防止有人从该主机试图攻击数据库系统max_connect_errors10# 服务端使用的字符集默认为UTF8character-set-serverutf8mb4# 创建新表时将使用的默认存储引擎default-storage-engineINNODB# 默认使用“mysql_native_password”插件认证mysql_native_passwordON#default_authentication_pluginmysql_native_password[mysql]# 设置mysql客户端默认字符集default-character-setutf8mb4[client]# 设置mysql客户端连接服务端时默认使用的端口port3306socket/public/mysqldb/tmp/mysql.sockln-s/etc/mysql/my_3306.cnf /etc/my_3306.cnfchown-Rmysql:mysql /usr/local/mysql8.4.2chown-Rmysql:mysql /public/mysqldbchown-Rmysql:mysql /etc/mysql初始化数据库cd/usr/local/mysql8.4.2/bin ./mysqld --defaults-file/etc/my_3306.cnf--initialize--console查看临时密码greppassword/public/mysqldb/logs/mysql_3306-error.log[rootvm172-16-0-6 bin]# ./mysqld --defaults-file/etc/my_3306.cnf --initialize --console2024-08-26T09:53:04.661185Z0[System][MY-015017][Server]MySQL Server Initialization - start.2024-08-26T09:53:04.664608Z0[System][MY-013169][Server]/usr/local/mysql-8.4.2/bin/mysqld(mysqld8.4.2)initializing of serverinprogress as process310692024-08-26T09:53:04.688642Z1[System][MY-013576][InnoDB]InnoDB initialization has started.2024-08-26T09:53:06.509597Z1[System][MY-013577][InnoDB]InnoDB initialization has ended.2024-08-26T09:53:10.162534Z6[Note][MY-010454][Server]A temporary password is generatedforrootlocalhost: WXyl%a7pZms2024-08-26T09:53:13.891230Z0[System][MY-015018][Server]MySQL Server Initialization - end.启动mysql服务器./mysqld_safe --defaults-file/etc/my_3306.cnf[rootvm172-16-0-6 support-files]# netstat -nltp | grep 3306tcp600:::33060 :::* LISTEN20232/mysqld tcp600:::3306 :::* LISTEN20232/mysqld登录mysql[rootcentos7-05145 bin]# mysql -u root -pEnter password: Welcome to the MySQL monitor. Commands end with;or\g. Your MySQL connectionidis10Server version:8.4.2 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. Typehelp;or\hforhelp. Type\ctoclearthe current input statement. mysql修改root密码mysqlALTERUSERrootlocalhostIDENTIFIEDWITHmysql_native_passwordBYyourpassword;mysqlusemysql;Readingtableinformationforcompletionoftableandcolumnnames You can turnoffthis featuretoget a quicker startupwith-ADatabasechanged mysqlmysqlselectuser,hostfromuser;-----------------------------|user|host|-----------------------------|root|localhost||mysql.infoschema|localhost||mysql.session|localhost||mysql.sys|localhost|-----------------------------4rowsinset(0.00sec)mysqlUPDATEUSERSEThost%WHEREuserroot;mysqlFLUSHPRIVILEGES;mysqlexit关闭mysql服务bash./mysqladmin-h127.0.0.1-u root-P3306-pshutdown配置systemd服务脚本cd/usr/local/mysql8.4.2/support-filesvimmysqld.service[Unit]DescriptionMySQL ServerDocumentationman:mysqld(8)Documentationhttp://dev.mysql.com/doc/refman/en/using-systemd.htmlAfternetwork.targetAftersyslog.target[Install]WantedBymulti-user.target[Service]UsermysqlGroupmysql# Have mysqld write its state to the systemd notify socketTypenotify# Disable service start and stop timeout logic of systemd for mysqld service.TimeoutSec0# Start main serviceExecStart/usr/local/mysql-8.4.2/bin/mysqld --defaults-file/etc/my_3306.cnf$MYSQLD_OPTS# Use this to switch malloc implementationEnvironmentFile-/etc/sysconfig/mysql# Sets open_files_limitLimitNOFILE141082Restarton-failureRestartPreventExitStatus1# Set environment variable MYSQLD_PARENT_PID. This is required for restart.EnvironmentMYSQLD_PARENT_PID1PrivateTmpfalseln-s/usr/local/mysql8.4.2/support-files/mysqld.service /etc/systemd/system/systemctl daemon-reload systemctl start mysqld登录数据库测试/usr/local/mysql8.4.2/bin/mysql-uroot-p-S/public/mysqldb/tmp/mysql.sock使用IP登录mysql bash mysql -u root -h 127.0.0.1 -pWelcome to the MySQL monitor. Commands end with;or\g. Your MySQL connectionidis16Server version:8.4.2 MySQL Community Server - GPL 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. Typehelp;or\hforhelp. Type\ctoclearthe current input statement. mysqlselectversion;-----------|version|-----------|8.4.2|-----------1rowinset(0.00sec)

相关新闻

最新新闻

SerenityOS 命令行选项解析指南:getopt 与 getopt_long 用法、返回值与底层实现

SerenityOS 命令行选项解析指南:getopt 与 getopt_long 用法、返回值与底层实现

SerenityOS 命令行选项解析指南:getopt 与 getopt_long 用法、返回值与底层实现 【免费下载链接】serenity The Serenity Operating System 🐞 项目地址: https://gitcode.com/GitHub_Trending/se/serenity 导读 本文以 getopt(3) 手册 为核心&a…

2026/9/23 4:54:42
轻量服务器还是ECS?大促云服务器选购与避坑实战指南

轻量服务器还是ECS?大促云服务器选购与避坑实战指南

每年大促节点,群里永远有人在问同一个问题:“38元的轻量服务器到底怎么抢?为什么我每次点进去都是已售罄?68元直购和99元的ECS我到底选哪个?”作为一个常年帮团队和自己采购云服务器的老用户,我太清楚这种纠…

2026/9/21 18:32:39
为 AI 代理的 Review 动作编写 Cedar 审批门控策略:review-agent-governance 策略编写实战指南

为 AI 代理的 Review 动作编写 Cedar 审批门控策略:review-agent-governance 策略编写实战指南

为 AI 代理的 Review 动作编写 Cedar 审批门控策略:review-agent-governance 策略编写实战指南 【免费下载链接】agents Multi-harness agentic plugin marketplace for Claude Code, Codex, Cursor, OpenCode, GitHub Copilot, and Google Antigravity 项目地址:…

2026/9/21 18:31:24
PaddleOCR 手写数学公式识别算法 CAN 实战指南:Counting-Aware Network 训练、评估与推理部署

PaddleOCR 手写数学公式识别算法 CAN 实战指南:Counting-Aware Network 训练、评估与推理部署

PaddleOCR 手写数学公式识别算法 CAN 实战指南:Counting-Aware Network 训练、评估与推理部署 【免费下载链接】PaddleOCR Turn any PDF or image document into structured data for your AI. A powerful, lightweight OCR toolkit that bridges the gap between i…

2026/9/21 18:31:34
Spring源码解析:构造器注入的类型转换与候选匹配机制

Spring源码解析:构造器注入的类型转换与候选匹配机制

/* MD / 富文本中的 .toc(含博客园搬家等嵌套结构);.toc-box 在侧栏,不受影响 */#content_views .toc,/* 编辑器常在目录前后插入空 p(:empty 仍占 20px),一并去掉避免顶空隙 */#content_views.markdown_views > p:empty:has(+ .toc),#content_views.markdown_views …

2026/9/21 18:31:25
openai-agents-python 多模型接入指南:深入解析 AnyLLMModel 适配层与 any-llm 路由

openai-agents-python 多模型接入指南:深入解析 AnyLLMModel 适配层与 any-llm 路由

openai-agents-python 多模型接入指南:深入解析 AnyLLMModel 适配层与 any-llm 路由 【免费下载链接】openai-agents-python A lightweight, powerful framework for multi-agent workflows 项目地址: https://gitcode.com/GitHub_Trending/op/openai-agents-pyth…

2026/9/21 18:31:13

日新闻

周新闻