1、更新软件包列表
apt-get update
2、查看系统默认安装的数据库版本
apt-cache policy mysql-server
3、需要安装mysql5.7的版本就需要换源
养成习惯,先备份文件:
cp /etc/apt/sources.list /etc/apt/sources.list.back
然后更换apt源:修改sources.list文件
vim /etc/apt/sources.list
# 阿里源
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
更新镜像源
gpg --keyserver keyserver.ubuntu.com --recv 3B4FE6ACC0B21F32
gpg --export --armor 3B4FE6ACC0B21F32 | apt-key add -
apt-get update
查看默认安装的mysql数据库版本,可以看到默认的已经变成了mysql5.7的版本了
4、安装MySQL并查看是否安装完成(安装过程中需要确认的直接默认点ok进入下一步即可)
apt-get -y install mysql-server-5.7
## 查看mysql是否安装成功
dpkg -l | grep mysql
mysql -V
systemctl status mysql
设置开机自启:
systemctl enable mysql
5、修改服务为全网启动
6、换回apt源
cd /etc/apt
mv sources.list sources.list.old
mv sources.list.back sources.list
apt-get update
7、设置允许远程访问
标签:bionic,步骤,MySQL5.7,Linux,aliyun,ubuntu,main,com,restricted From: https://blog.csdn.net/Trisyp/article/details/141860593use mysql;
update user set host='%' where user = 'root' and host='localhost';
grant all privileges on *.* to 'root'@'%' identified by 'root' with grant option;
flush privileges;