Install MySQL database on Debian 10

First, go here and look for the most recent version of mysql-apt-config _ * _ all.deb. I had this file mysql-apt-config_0.8.17-1_all.deb. Download and install:

wget https://repo.mysql.com/mysql-apt-config_0.8.17-1_all.deb
sudo dpkg -i mysql-apt-config_0.8.17-1_all.deb

During the installation process, you can select the desired MySQL version, by default it was the 8th version. If you required to change it again, then the command will help:

sudo dpkg-reconfigure mysql-apt-config

Next installation:

sudo apt-get update

sudo apt install mysql-server mysql-client

You can restart the service with command:

systemctl restart mysql

To secure an installation please edit:

/usr/bin/mysql_secure_installation

Now it’s time to connect the database:

mysql -u root -p

To remove previous installation it worked based on StackExchange:

  1. Get the list of MySQL packages installed on the system by executing the command sudo dpkg -l | grep mysql
  2. Remove the the packages shown above by executing the command sudo apt-get --purge autoremove <packages from the step 1>
  3. Delete /var/lib/mysql
  4. Try to install mysql again. It should solve your problem.