公司动态

mysql 8.0.45 二进制安装配置

📅 2026/8/25 10:57:54
mysql 8.0.45 二进制安装配置
mysql 8.0.45 二进制安装配置在安装MySQL8.0.45的过程中遇到一些疑问特此记录。检查配置前提条件# 检查是否安装 rpm -qa | grep -E mariadb|mysql rpm -e --nodeps mariadb-libs mariadb-server mariadb 2/dev/null groupadd mysql useradd -r -g mysql -s /bin/false mysql tar -Jxvf mysql-8.0.45-linux-glibc2.17-x86_64.tar.xz ln -s mysql-8.0.45-linux-glibc2.17-x86_64 mysqlmy.cnf配置如下cat /etc/my.cnf EOF [mysqld] basedir/data/mysql-8.0.45 datadir/data/mysql-8.0.45/data port23306 socket/data/mysql-8.0.45/mysql.sock log-error/data/mysql-8.0.45/data/error_mysqld.log pid-file/data/mysql-8.0.45/data/mysqld.pid default-time-zone 08:00 lc-messages-dir /data/mysql-8.0.45/share lc-messages en_US server_id125 log-binmysql-bin binlog_expire_logs_seconds 604800 #为7天 max_binlog_size 512M innodb_buffer_pool_size 2G innodb_buffer_pool_instances 8 # 多实例提高并发 innodb_file_per_table ON innodb_max_dirty_pages_pct 75 # 减少突发刷盘 innodb_log_buffer_size 64M # 日志缓冲区大小 innodb_redo_log_capacity 1G lower_case_table_names1 max_connections1000 wait_timeout1800 interactive_timeout1800 #单位s skip-name-resolve ON # 锁相关优化 innodb_lock_wait_timeout 50 # 锁等待超时时间 innodb_deadlock_detect ON # 死锁检测 innodb_print_all_deadlocks ON # 记录所有死锁信息 # 慢查询日志 slow_query_log ON slow_query_log_file /data/mysql/data/slow.log long_query_time 2 # 临时表存储在内存避免磁盘临时表 tmp_table_size 64M max_heap_table_size 64M [mysql] socket/data/mysql/mysql.sock [client] socket/data/mysql/mysql.sock EOF首先遇到的错误是[ERROR] [MY-010338] [Server] Cant find error-message file /data/mysql-8.0.45/data/share/errmsg.sys. Check error-message file location and lc-messages-dir configuration directive.一、问题根源errmsg.sys 是 MySQL 的错误消息库默认位于安装根目录的 share/ 或 share/english/ 下。你的配置把 lc-messages-dir 指向了数据目录/data/mysql-8.0.45/data/而非安装根目录。二、解决方案Linux 通用确认正确路径假设你的 MySQL 解压 / 安装在/data/mysql-8.0.45/那么basedir (安装根目录): /data/mysql-8.0.45/正确的 share 目录: /data/mysql-8.0.45/share/errmsg.sys 真实路径: /data/mysql-8.0.45/share/english/errmsg.sys还有一些告警信息2026-04-22T01:05:40.030766Z 0 [Warning] [MY-011070] [Server] binlog_format is deprecated and will be removed in a future release. 2026-04-22T01:05:40.030921Z 0 [System] [MY-013169] [Server] /data/mysql/bin/mysqld (mysqld 8.0.45) initializing of server in progress as process 103592 2026-04-22T01:05:40.038863Z 0 [Warning] [MY-013907] [InnoDB] Deprecated configuration parameters innodb_log_file_size and/or innodb_log_files_in_group have been used to compute innodb_redo_log_capacity3221225472. Please use innodb_redo_log_capacity instead. 2026-04-22T01:05:40.040969Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started. 2026-04-22T01:05:41.327655Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended. 2026-04-22T01:05:42.578567Z 0 [Warning] [MY-013829] [Server] Missing data directory for ICU regular expressions: /data/mysql-8.0.45/data/lib/private/. 2026-04-22T01:05:44.190399Z 6 [Note] [MY-010454] [Server] A temporary password is generated for rootlocalhost: 1gA6,adapdytWarningbinlog_format 已废弃plaintext[Warning] [MY-011070] [Server] ‘binlog_format’ is deprecated原因MySQL 8.0 默认就是行模式binlog_format 参数已经废弃了。解决直接删掉 my.cnf 里的 binlog_format 这一行即可。Warninginnodb_log_file_size 已废弃plaintext[Warning] [MY-013907] [InnoDB] Deprecated configuration parameters innodb_log_file_size …原因MySQL 8.0.30 以后用新参数 innodb_redo_log_capacity 代替了旧的两个参数。重新初始化/data/mysql-8.0.45/bin/mysqld --defaults-file/etc/my.cnf --initialize --usermysql \ --basedir/data/mysql-8.0.45 --datadir/data/mysql-8.0.45/data调整完参数之后再次初始化。不在出现ERROR WARNING信息cat /data/mysql-8.0.45/data/error_mysqld.log [rootgaacdc01 data]# cat error_mysqld.log 2026-04-22T01:17:07.800740Z 0 [System] [MY-013169] [Server] /data/mysql/bin/mysqld (mysqld 8.0.45) initializing of server in progress as process 110009 2026-04-22T01:17:07.812077Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started. 2026-04-22T01:17:09.034907Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended. 2026-04-22T01:17:12.089398Z 6 [Note] [MY-010454] [Server] A temporary password is generated for rootlocalhost: 3LX#TyZC5设置启动脚本cat /usr/lib/systemd/system/mysqld.service EOF [Unit] DescriptionMySQL Server Documentationman:mysqld(8) Documentationhttp://dev.mysql.com/doc/refman/en/using-systemd.html Afternetwork.target Aftersyslog.target [Install] WantedBymulti-user.target [Service] Usermysql Groupmysql ExecStart/data/mysql-8.0.45/bin/mysqld_safe --defaults-file/etc/my.cnf EOF systemctl daemon-reload systemctl enable mysqld systemctl start mysqld systemctl status mysqld重置密码mysql -uroot -p -P23306 -S /data/mysql-8.0.45/mysql.sock ALTER USER rootlocalhost IDENTIFIED BY Gaamydb2026; create user root% identified by Gaamydb2026; grant all privileges on *.* to root%; flush privileges;