1. 首先输入mysql --version看有没有安装过其他版本的mysql,有的话卸载掉
apt-get remove mysql-common
apt-get remove mysql*
2. 下载包并解压升级
下载地址:https://repo.mysql.com//mysql-apt-config_0.8.10-1_all.deb
sudo dpkg -i mysql-apt-config_0.8.9-1_all.deb
sudo apt-get update
若更新过程中出现错误:EXPKEYSIG 8C718D3B5072E1F5 MySQL Release Engineering
执行以下操作再次更新就OK
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 8C718D3B5072E1F5
sudo apt-get update
3. 安装mysql
sudo apt-get install mysql-server mysql-common
若是报如下错:
换成下面源(vi /etc/apt/sources.list),然后再apt-get update
deb http://mirrors.aliyun.com/debian/ stretch main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ stretch main non-free contrib
deb http://mirrors.aliyun.com/debian-security stretch/updates main
deb-src http://mirrors.aliyun.com/debian-security stretch/updates main
deb http://mirrors.aliyun.com/debian/ stretch-updates main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ stretch-updates main non-free contrib
deb http://mirrors.aliyun.com/debian/ stretch-backports main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ stretch-backports main non-free contrib
再次执行安装 sudo apt-get install mysql-server mysql-common
4. 启动mysql5.7
service mysql start
5. 添加访问权限
vi /etc/mysql/mysql.conf.d/mysqld.cnf
bind-address = 0.0.0.0