sudo apt-get purge mysql-server mysql-client mysql-common mysql-server-core-* mysql-client-core-*
sudo rm -rf /etc/mysql /var/lib/mysql
sudo apt-get autoremove
sudo apt-get autoclean2. Now we need to download and install the under listed package so that we can select the installation repository.
wget http://repo.mysql.com/mysql-apt-config_0.8.10-1_all.deb
sudo dpkg -i mysql-apt-config_0.8.10-1_all.deb- choose the option "MySQL Server & Cluster (Currently selected: mysql-8.0)" from the list and press Ok.
- Select MySQL5.7 from it to complete the installation of MySQL 5.7
sudo dpkg-reconfigure mysql-apt-config
sudo apt updatesudo apt-cache policy mysql-serverVERSION=5.7.31-1ubuntu18.04
sudo mkdir -p /etc/mysql/conf.d
sudo apt install -f mysql-client=$VERSION
sudo apt install -f mysql-community-server=$VERSION
sudo apt install -f mysql-server=$VERSIONsudo nano /etc/apt/preferences.d/mysqladd the lines
Package: mysql-server
Pin: version 5.7.31-1ubuntu18.04
Pin-Priority: 1001
Package: mysql-client
Pin: version 5.7.31-1ubuntu18.04
Pin-Priority: 1001
Package: mysql-community-server
Pin: version 5.7.31-1ubuntu18.04
Pin-Priority: 1001
Package: mysql-community-client
Pin: version 5.7.31-1ubuntu18.04
Pin-Priority: 1001
Package: mysql-apt-config
Pin: version 0.8.10-1
Pin-Priority: 1001save and exit file
mysql_secure_installationYou may need to install libmysqlclient-dev to install certains gems like mysql2 0.4.4
sudo apt install -f libmysqlclient-dev=5.7.31-1ubuntu18.04extras
mysql -u root -p -h localhost
mysql> CREATE USER 'user'@'localhost' IDENTIFIED BY 'password';
mysql> GRANT ALL PRIVILEGES ON * . * TO 'novousuario'@'localhost';