You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

通过Brew安装的MySQL从8.2降级到8.0.35后无法启动

MySQL跨版本降级启动失败问题解决

操作过程

  • 执行brew install mysql安装8.2版本,因与Workbench不兼容,执行brew uninstall mysql卸载
  • 安装8.0系列最新版本:brew install mysql@8.0
  • 重启服务:brew services restart mysql@8.0
  • 执行初始化命令mysql_secure_installation,输入密码后报错:

    Error: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

已尝试的无效方案

  • 在my.cnf中配置127.0.0.1——已设置但无效
  • 在my.cnf添加socket=/var/lib/mysql/mysql.sock——重启后无效
  • 使用mysql -h 127.0.0.1 -P 3306 -u root -p连接——失败

关键错误日志

运行mysqld后输出核心错误:

2023-12-14T23:37:41.322399Z 0 [System] [MY-010116] [Server] /opt/homebrew/Cellar/mysql@8.0/8.0.35/bin/mysqld (mysqld 8.0.35) starting as process 13478
2023-12-14T23:37:41.324735Z 0 [Warning] [MY-010159] [Server] Setting lower_case_table_names=2 because file system for /opt/homebrew/var/mysql/ is case insensitive
2023-12-14T23:37:41.329772Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2023-12-14T23:38:00.170514Z 1 [ERROR] [MY-014061] [InnoDB] Invalid MySQL server downgrade: Cannot downgrade from 80200 to 80035. Downgrade is only permitted between patch releases.
mysqld: Can't open file: 'mysql.ibd' (errno: 0 - )
2023-12-14T23:38:00.226999Z 1 [ERROR] [MY-010334] [Server] Failed to initialize DD Storage Engine
2023-12-14T23:38:00.227083Z 0 [ERROR] [MY-010020] [Server] Data Dictionary initialization failed.
2023-12-14T23:38:00.227093Z 0 [ERROR] [MY-010119] [Server] Aborting
2023-12-14T23:38:00.228201Z 0 [System] [MY-010910] [Server] /opt/homebrew/Cellar/mysql@8.0/8.0.35/bin/mysqld: Shutdown complete (mysqld 8.0.35)  Homebrew.

解决办法

问题根源是卸载8.2版本时未清理旧数据目录,8.2的InnoDB数据文件无法被8.0版本兼容读取,需彻底清理后重新初始化:

  1. 停止所有MySQL服务:
    brew services stop mysql@8.0
    
  2. 备份旧数据目录(可选,需保留旧数据时执行):
    sudo mv /opt/homebrew/var/mysql /opt/homebrew/var/mysql_backup
    
    若无需保留旧数据,直接删除:
    sudo rm -rf /opt/homebrew/var/mysql
    
  3. 重新初始化MySQL:
    mysqld --initialize --user=_mysql --basedir=/opt/homebrew/Cellar/mysql@8.0/8.0.35 --datadir=/opt/homebrew/var/mysql
    
  4. 启动MySQL服务:
    brew services start mysql@8.0
    
  5. 查看临时初始密码(用于后续安全初始化):
    grep 'temporary password' /opt/homebrew/var/mysql/*.err
    
  6. 执行安全初始化命令,输入临时密码后设置新密码并完成配置:
    mysql_secure_installation
    

内容的提问来源于stack exchange,提问作者Jossy

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.04 01:24:56