Skip to content

Instantly share code, notes, and snippets.

@GQuirino
Created August 18, 2020 22:12
Show Gist options
  • Select an option

  • Save GQuirino/005c312461833ccd742df1de9f385963 to your computer and use it in GitHub Desktop.

Select an option

Save GQuirino/005c312461833ccd742df1de9f385963 to your computer and use it in GitHub Desktop.
How to install mysql 5.7 into Ubuntu 20.04

How to install MySQL Server 5.7 on Ubuntu 20.04 LTS (Focal Fossa)

1. Remove any version other than MySQL Server 5.7

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 autoclean

2. 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

3. configure mysql-apt-config

sudo dpkg-reconfigure mysql-apt-config
sudo apt update

4. Choose the properly version to install

sudo apt-cache policy mysql-server

untitled

VERSION=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=$VERSION

5. Create under listed file to add the configuration items:

sudo nano /etc/apt/preferences.d/mysql

add 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: 1001

save and exit file

6. set root password

mysql_secure_installation

You 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.04

extras

mysql -u root -p -h localhost
mysql> CREATE USER 'user'@'localhost' IDENTIFIED BY 'password';
mysql> GRANT ALL PRIVILEGES ON * . * TO 'novousuario'@'localhost';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment