All we need is an easy explanation of the problem, so here it is.
I have MySQL installed on my test server (Debian 10). I recently updated it to the newest version (8.0.29), but there are some issues with it so I want to go back to an older version (8.0.28). But I can’t for the life of me figure out how to do so.
I have removed the existing database, and tried to re-install it using:
apt-get install mysql-server=8.0.28-1debian10
but that didn’t work, and suggested I run:
apt --fix-broken install
which of course upgraded it to the latest version again.
I have tried numerous variations of this,but all result in mysql-server can't be found
or similar errors.
I have been scouring the internet, and there seems to be lots of people asking similar questions, but no real solutions. Even the official MySQL documentation glosses over this bit.
Can it be done? And if so, how?
It’s only a test database so I have no issues with scrapping it and starting again.
How to solve :
I know you bored from this bug, So we are here to help you! Take a deep breath and look at the explanation of your problem. We have many solutions to this problem, But we recommend you to use the first method because it is tested & true method that will 100% work for you.
Method 1
If you have data first make a backup.
To completely uninstall MySQL
follow below steps:
sudo apt-get purge mysql*
sudo apt-get autoremove
sudo apt-get autoclean
sudo apt-get dist-upgrade
sudo rm -rf /etc/mysql
sudo rm -rf /var/lib/mysql*
To install MySQL 8.0.22
add the MySQL Software Repository
sudo apt update
sudo apt install gnupg
Download mysql-server_8.0.22-1debian10_amd64.deb-bundle.tar
from MySQL archive or using wget :
wget https://downloads.mysql.com/archives/get/p/23/file/mysql-server_8.0.22-1debian10_amd64.deb-bundle.tar
Once the download is completed install the package :
sudo dpkg -i mysql-apt-config*
During the installation, you’ll be presented with a configuration screen where you can specify which version of MySQL you’d prefer, along with an option to install repositories for other MySQL-related tools. Choose the one you need.
Refresh your apt package cache to make the new software packages available:
sudo apt update
Having added the repository and with your package cache freshly updated, now you can use apt to install the latest MySQL server package:
sudo apt install mysql-server
MySQL should be installed and running now. Check by using systemctl:
sudo systemctl status mysql
Do not forget to secure MySQL using
mysql_secure_installation
Refrences
https://www.digitalocean.com/community/tutorials/how-to-install-the-latest-mysql-on-debian-10
Method 2
So I got there in the end. This may not all be strictly correct, and there may be better ways to do this, however it works for me:
-
Take a MySQLDump backup first if required.
-
Remove the Old MySQL Version
systemctl stop mysql
apt-get remove --purge 'mysql-.*'
apt-get autoremove
apt-get autoclean
apt-get dist-upgrade
rm -rf /etc/mysql
rm -rf /var/lib/mysql*
- Download the new version bundle
cd /root
wget https://downloads.mysql.com/archives/get/p/23/file/mysql-server_8.0.28-1debian10_amd64.deb-bundle.tar
- extract the files and install in this order
mkdir 828
tar -xvf mysql-server_8.0.28-1debian10_amd64.deb-bundle.tar -C /root/828
cd /root/828
dpkg -i libmysqlclient21_8.0.28-1debian10_amd64.deb
dpkg -i mysql-common_8.0.28-1debian10_amd64.deb
dpkg -i mysql-community-client-plugins_8.0.28-1debian10_amd64.deb
dpkg -i mysql-community-client-core_8.0.28-1debian10_amd64.deb
dpkg -i mysql-community-client_8.0.28-1debian10_amd64.deb
dpkg -i mysql-client_8.0.28-1debian10_amd64.deb
dpkg -i mysql-community-server-core_8.0.28-1debian10_amd64.deb
apt --fix-broken install
dpkg -i mysql-community-server-core_8.0.28-1debian10_amd64.deb
dpkg -i mysql-community-server_8.0.28-1debian10_amd64.deb
dpkg -i mysql-server_8.0.28-1debian10_amd64.deb
It should now be working with the correct version:
systemctl status mysql
mysqld- V
/usr/sbin/mysqld Ver 8.0.28 for Linux on x86_64 (MySQL Community Server - GPL)
Finally, secure the database
mysql_secure_installation
Note: Use and implement method 1 because this method fully tested our system.
Thank you 🙂
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0