1.Ubuntu换源(阿里云)
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
sudo vi /etc/apt/sources.list
deb http://mirrors.aliyun.com/ubuntu/ xenial main multiverse restricted universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main multiverse restricted universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-proposed main multiverse restricted universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main multiverse restricted universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main multiverse restricted universe
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main multiverse restricted universe
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-proposed main multiverse restricted universe
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main multiverse restricted universe
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main multiverse restricted universe
sudo apt update
2.在MySQL官网下载mysql-apt-config_*.*.**-*_all.deb包
3、解包
sudo dpkg -i mysql-apt-config_0.8.14-1_all.deb
选择默认,用方向键使框体选择确定,按enter键即可
执行完成后,执行sudo apt update命令
4、安装
使用sudo apt install mysql-server命令,就会安装MySQL8.0
中途会弹出对话框,输入密码即可,此密码即MySQL中root登录密码
MySQL8.0采用了新的加密方式,一定要注意,正是因为这个加密方式才导致Ubuntu18.04用设置的root密码登录不了MySQL,因为Ubuntu18.04的终端可能有问题,并不支持这个新的加密方式。幸好有界面可以让我们选择使用旧版本5.x的加密方式,所以果断选择采用5.x的加密方式。
随后等待安装完成即可
mysql -uroot -p