官网下载mysql:MySQL :: Download MySQL Community Server
将mysql-server_8.0.20-2ubuntu20.04_amd64.deb-bundle.tar上传到/usr/local/src
#解压压缩文件
tar -xvf mysql-server_8.0.20-2ubuntu20.04_amd64.deb-bundle.tar
解压依赖包依次输入命令
sudo dpkg -i mysql-community-client-core_8.0.20-2ubuntu20.04_amd64.deb
sudo dpkg -i mysql-common_8.0.20-2ubuntu20.04_amd64.deb
sudo dpkg -i mysql-community-client_8.0.20-2ubuntu20.04_amd64.deb
sudo dpkg -i libmysqlclient21_8.0.20-2ubuntu20.04_amd64.deb
sudo dpkg -i libmysqlclient-dev_8.0.20-2ubuntu20.04_amd64.deb
sudo dpkg -i mysql-client_8.0.20-2ubuntu20.04_amd64.deb
如果安装 sudo dpkg -i mysql-community-server-core_8.0.20-2ubuntu20.04_amd64.deb提示
需要下载依赖包
进入https://pkgs.org/download/libmecab2
访问http://security.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.1-1ubuntu2.1~18.04.23_amd64.deb 下载
分别执行
dpkg -i libmecab2_0.996-14build9_amd64.deb
sudo dpkg -i libssl1.1_1.1.1-1ubuntu2.1~18.04.23_amd64.deb
依赖包安装后执行
sudo dpkg -i mysql-community-server-core_8.0.20-2ubuntu20.04_amd64.deb
sudo dpkg -i mysql-community-server_8.0.20-2ubuntu20.04_amd64.deb
执行后,会弹出窗口设置mysql密码,设置为root,
选择第二行 5.X加密
sudo dpkg -i mysql-server_8.0.20-2ubuntu20.04_amd64.deb
sudo service mysql restart
启动mysql,输入root
mysql -uroot -p
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';flush privileges;
#更改root连接权限
use mysql;
update user set host='%' where user = 'root';
flush privileges;