1.添加mysql apt 仓库
sudo apt update
sudo apt install wget -y
wget <https://dev.mysql.com/get/mysql-apt-config_0.8.12-1_all.deb>
sudo dpkg -i mysql-apt-config_0.8.12-1_all.deb
安装过程中,弹出选择框,
step1 选择 Ubuntu Bionic
step2 MySQL 8.0 chosen by default
step3 选择 MySQL 5.7 server
step4 MySQL5.7 by default
2 更新仓库
sudo apt-get update
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys
$ sudo apt-cache policy mysql-server
mysql-server:
Installed: (none)
Candidate: 8.0.26-0ubuntu0.20.04.2
Version table:
8.0.26-0ubuntu0.20.04.2 500
500 <http://mirrors.digitalocean.com/ubuntu> focal-updates/main amd64 Packages
500 <http://security.ubuntu.com/ubuntu> focal-security/main amd64 Packages
8.0.19-0ubuntu5 500
500 <http://mirrors.digitalocean.com/ubuntu> focal/main amd64 Packages
5.7.35-1ubuntu18.04 500
500 <http://repo.mysql.com/apt/ubuntu> bionic/mysql-5.7 amd64 Packages
3 安装mysql5.7
sudo apt install -fy mysql-client=5.7* mysql-community-server=5.7* mysql-server=5.7*
4 添加新的mysql用户(不建议使用root用户)
uninstall plugin validate_password; #关闭密码强度校验,如果你想使用简单密码
CREATE USER 'user'@'%' IDENTIFIED BY 'MyStrongPass.';
GRANT ALL PRIVILEGES ON * . * TO 'user'@'%';
FLUSH PRIVILEGES;