当前位置: 首页 > news >正文

mysql 8.0.30安装部署

环境:
OS:Centos 7
mysql:8.0.30

1.下载安装介质
官网下载
我这里下载的是8.0.30
mysql-8.0.43-linux-glibc2.17-x86_64.tar.xz

注意这里是glibc2.17(centos 7系统默认的最高版本)

 

2.创建mysql用户和用户组
#groupadd mysql
#useradd -g mysql mysql
#passwd mysql

3.下载解压安装
[root@localhost soft]# cd /soft
[root@localhost soft]# tar -xvf mysql-8.0.30-linux-glibc2.12-x86_64.tar.xz
[root@localhost soft]# mv mysql-8.0.30-linux-glibc2.12-x86_64 /opt/mysql8

4.创建相应的目录
[root@node1 mysql8]# cd /opt/mysql8
[root@localhost mysql8]# mkdir data ##数据文件目录
[root@localhost mysql8]# mkdir conf ## 配置文件目录
[root@localhost mysql8]# mkdir -p mysqllog/relaylog ##主从环境relaylog
[root@localhost mysql8]# mkdir -p mysqllog/logfile ##错误日志文件
[root@localhost mysql8]# mkdir -p mysqllog/binlog ##binlog文件
[root@localhost mysql8]# mkdir -p secure_file ##secure_file_priv参数指定路
[root@localhost mysql8]# mkdir /opt/mysql8/audit ##审计目录

 

5.初始化数据库
root账户下

[root@localhost bin]# cd /opt/mysql8/bin
[root@localhost bin]# ./mysqld --initialize --lower-case-table-names=1 --user=mysql --basedir=/opt/mysql8 --datadir=/opt/mysql8/data
2026-04-21T01:56:32.630607Z 0 [Warning] [MY-011070] [Server] 'Disabling symbolic links using --skip-symbolic-links (or equivalent) is the default. Consider not using this option as it' is deprecated and will be removed in a future release.
2026-04-21T01:56:32.630720Z 0 [System] [MY-013169] [Server] /opt/mysql8/bin/mysqld (mysqld 8.0.30) initializing of server in progress as process 5184
2026-04-21T01:56:32.640277Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2026-04-21T01:56:33.940950Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2026-04-21T01:56:35.834278Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: oc3lzeLS=C#W

 

6.配置文件

[root@node1 conf]# more my.cnf 
[mysqld]
port=3306
server-id=3
basedir=/opt/mysql8
datadir=/opt/mysql8/data
socket=/opt/mysql8/mysql.sock
max_connections = 1000
character_set_server=utf8mb4
collation-server=utf8mb4_general_ci
init_connect='SET collation_connection = utf8mb4_general_ci'
init_connect='SET NAMES utf8mb4'
interactive_timeout=86400
wait_timeout=86400
skip-external-locking
key_buffer_size= 128M
max_allowed_packet=32M
##query_cache_size=32M
read_buffer_size=2M
sort_buffer_size=1M
join_buffer_size= 128M
innodb_file_per_table= 1
innodb_open_files= 5000
innodb_buffer_pool_size= 4G
innodb_write_io_threads= 16
innodb_read_io_threads= 16
innodb_thread_concurrency = 0
innodb_purge_threads= 1
innodb_flush_log_at_trx_commit= 2
innodb_log_buffer_size=16M
##准备废弃innodb_log_file_size和innodb_log_files_in_group,使用innodb_redo_log_capacity代替
##innodb_log_file_size=512M
##innodb_log_files_in_group= 5
innodb_redo_log_capacity = 2GB
innodb_max_dirty_pages_pct= 90
innodb_lock_wait_timeout= 120
bulk_insert_buffer_size= 64M
myisam_sort_buffer_size=64M
myisam_max_sort_file_size= 1G
##myisam_repair_threads= 1
log_bin_trust_function_creators=1
event_scheduler=1
max_binlog_size=100M
binlog_format=row
log-bin=/opt/mysql8/mysqllog/binlog/binlog.bin
slow_query_log=on
slow_query_log_file=/opt/mysql8/mysqllog/logfile/slow-query.log
long_query_time=1
log_queries_not_using_indexes=on
log-error=/opt/mysql8/mysqllog/logfile/mysql-err.log
binlog_cache_size=4MB
##skip-host-cache
skip-name-resolve
##已经没有该参数了expire_logs_days=15
##3*24*60*60=259200 3天
binlog_expire_logs_seconds=259200
##skip_replica_start
##skip-slave-start
skip_replica_start
relay-log-index=/opt/mysql8/mysqllog/relaylog/slave-relay-bin.index
relay-log=/opt/mysql8/mysqllog/relaylog/relaylog-binlog
replicate-ignore-db=information_schema,performance_schema,sys
replica_net_timeout=60
##language=/opt/mysql8/share/english
early-plugin-load=""
explicit_defaults_for_timestamp=true
log_replica_updates=1
##log_slave_updates=1
gtid_mode=ON
enforce_gtid_consistency = ON
lower_case_table_names=1
sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO'
secure_file_priv=/opt/mysql8/secure_file
##default_authentication_plugin=mysql_native_password
authentication_policy=mysql_native_password[client]
port = 3306
default-character-set = utf8mb4[mysqldump]
quick
max_allowed_packet = 32M
[myisamchk]
key_buffer_size = 8M
sort_buffer_size = 8M
read_buffer = 4M
write_buffer = 4M

 

7.生成错误日志文件
[root@node1 opt]# echo>/opt/mysql8/mysqllog/logfile/mysql-err.log

 

8.修改目录权限
[root@localhost mha]# cd /opt
[root@localhost opt]# chown -R mysql:mysql ./mysql8

9.启动
(在root用户下执行)
[root@node1 opt]# /opt/mysql8/bin/mysqld_safe --defaults-file=/opt/mysql8/conf/my.cnf --user=mysql &


10.登陆数据库修改相应用户密码
[mysql@localhost bin]# cd /opt/mysql8/bin
[mysql@localhost bin]$ ./mysql -h localhost -uroot -P3306 -S /opt/mysql8/mysql.sock -p

mysql> select version();
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

提示修改密码
alter user 'root'@'localhost' identified by 'mysql';
flush privileges;

 

11.重新登录
[mysql@localhost bin]# cd /opt/mysql8/bin
[mysql@localhost bin]# ./mysql -h localhost -uroot -P3306 -S /opt/mysql8/mysql.sock -pmysql

http://www.jsqmd.com/news/676049/

相关文章:

  • 探讨能做简约新中式护墙板装修的公司,哪家性价比高 - 工业设备
  • 魔兽争霸III玩家必备:WarcraftHelper完全指南与优化技巧
  • Anaconda换源保姆级教程:Windows/Linux双系统配置清华、中科大源(含Pytorch镜像)
  • QQ音乐加密格式终极解密指南:使用qmcdump实现音频自由转换
  • 麒麟V10离线环境生存指南:如何在没有外网的情况下安装.deb包(附清华/中科大源地址)
  • Hotkey Detective:3分钟找出Windows热键冲突的“元凶“
  • EasyAnimateV5-7b-zh-InP在软件测试中的应用:自动化测试过程可视化
  • 20260421_095852_运维转行网络安全进步最快的方式:没有之一!
  • 大航海时代ol台服找Call记(十八)任务数据分析
  • 【2025微服务可观测性分水岭】:Spring Boot 4.0 Agent-Ready 架构如何重构APM链路——基于127个真实生产集群的压测数据
  • 思源宋体TTF终极指南:免费获取7种专业字重的完整中文解决方案
  • 上海家装公司施工队自营与外包的识别方法及对质量管控的影响 - 品牌排行榜
  • 【ROS2机器人实战进阶】参数动态配置:RCLCPP实现节点行为热切换
  • 告别Rufus和Etcher:用WoeUSB-ng在Linux/Mac上搞定Win10启动盘
  • 航空行业专用自动化测试系统
  • 别再花钱买显卡了!手把手教你用Google Colab免费跑通你的第一个Keras模型
  • 当远端表已经悄悄改了结构,我们该怎样检查 SAP HANA 里的 virtual table 定义
  • 企业年报服务系统/小微服务助手小程序源码带搭建教程
  • 3分钟学会:用Better Export PDF打造专业级文档
  • XXMI启动器终极指南:5分钟搞定多游戏模组管理的完整教程
  • 查看是否有锁表
  • DeepSeek-OCR开源大模型实践:对接LangChain构建文档智能问答系统
  • 2026上海GEO优化公司推荐:定制服务商实力榜(必看) - 品牌排行榜
  • Real Anime Z开发者指南:CUDA碎片治理与CPU卸载机制详解
  • Docker(二)
  • 2026年语义混合检索系统哪家专业:五家优选品牌对比 - 科技焦点
  • 鲸汤(上海)智能科技有限公司:以 AI 重构企业获客,一部手机就是一支 AI 获客团队 - 品牌企业推荐师(官方)
  • 保姆级教程:用ThinkBook 16+打造完美双系统开发环境(Win11+Ubuntu 20.04)
  • SpringBoot监听Redis键过期事件,实现订单超时自动关闭(附集群版避坑指南)
  • 把Netcat玩出花:从端口扫描到简易蜜罐,Windows下的5个实战场景演练