MySQL 8.0.34降级至8.0.28失败求助
Hey there, sorry to hear you're stuck with this downgrade issue—this is actually a common pitfall when dealing with MySQL version pinning on Ubuntu, so let's break down what might be going wrong and how to fix it:
1. First, verify what's actually installed
The reason you're still seeing 8.0.34 might be that only part of the MySQL stack was downgraded, while other core components (like client libraries or common packages) are still on the newer version. Run this command to list all MySQL-related packages and their versions:
dpkg -l | grep mysql
Look for lines like mysql-client, mysql-common, mysql-server-core-8.0—if any of these show 8.0.34, that's the root of the problem.
2. Ensure you fully purged all MySQL components (again)
It sounds like you tried removing MySQL, but sometimes residual packages or configs can cause unexpected behavior. Let's do a thorough cleanup:
- Purge all MySQL packages completely:
sudo apt purge mysql-server mysql-client mysql-common mysql-server-core-* mysql-client-core-* - Remove leftover unused dependencies:
sudo apt autoremove --purge - Clear cached packages to avoid pulling the wrong version accidentally:
sudo apt autoclean - Delete residual data directories (make sure you have a full backup first!):
sudo rm -rf /var/lib/mysql /etc/mysql
3. Install the full 8.0.28 stack (not just mysql-server)
When you only install mysql-server=8.0.28-0ubuntu4, APT might still pull in newer versions of its required dependencies. Instead, specify all core packages with the exact version to ensure everything downgrades together:
sudo apt install mysql-server=8.0.28-0ubuntu4 mysql-client=8.0.28-0ubuntu4 mysql-common=8.0.28-0ubuntu4 mysql-server-core-8.0=8.0.28-0ubuntu4 mysql-client-core-8.0=8.0.28-0ubuntu4
If you hit unmet dependency errors, double-check your APT sources. If you have an official MySQL APT repo in /etc/apt/sources.list.d/, comment it out temporarily, run sudo apt update, and try the install again—these repos often prioritize newer versions over Ubuntu's default packages.
4. Lock the versions to prevent accidental upgrades
Once you have 8.0.28 installed successfully, lock the packages so future apt upgrade commands don't automatically bump them back to 8.0.34:
sudo apt-mark hold mysql-server mysql-client mysql-common mysql-server-core-8.0 mysql-client-core-8.0
5. Verify the final version
After completing all steps, confirm the installed version with these commands:
mysql --version sudo mysqladmin version
That should get you on 8.0.28 properly. Let me know if you hit any dependency errors or other snags during this process!
备注:内容来源于stack exchange,提问作者Papa Joe Dee

