本文MySQL安装是在虚拟机中的Ubuntu20.04系统中进行,安装的MySQL为5.7.31
文章参考自博客中第二种安装方式
1、下载deb安装包
首先先查看电脑中Linux系统是32位还是64位
getconf LONG_BIT //如果返回32则是32位,64则为64位
安装包下载网址:MySQL :: Download MySQL Community Server (Archived Versions)
我的电脑是64位因此下载64位版本
# 新建目录
mkdir mysql5.7.31
mv mysql-server_5.7.31-1ubuntu18.04_amd64.deb-bundle.tar ./mysql5.7.31
# 解压
cd mysql5.7.31
sudo tar -vxf mysql-server_5.7.31-1ubuntu18.04_amd64.deb-bundle.tar
# 解压出来的deb安装包如下:
libmysqlclient20_5.7.31-1ubuntu18.04_amd64.deb
mysql-client_5.7.31-1ubuntu18.04_amd64.deb
mysql-community-source_5.7.31-1ubuntu18.04_amd64.deb
mysql-server_5.7.31-1ubuntu18.04_amd64.deb
mysql-common_5.7.31-1ubuntu18.04_amd64.deb
mysql-testsuite_5.7.31-1ubuntu18.04_amd64.deb
libmysqlclient-dev_5.7.31-1ubuntu18.04_amd64.deb
mysql-community-client_5.7.31-1ubuntu18.04_amd64.deb
mysql-community-server_5.7.31-1ubuntu18.04_amd64.deb
libmysqld-dev_5.7.31-1ubuntu18.04_amd64.deb
mysql-community-test_5.7.31-1ubuntu18.04_amd64.deb
# 删除2个测试相关的包
sudo rm -f mysql-testsuite_5.7.31-1ubuntu18.04_amd64.deb
sudo rm -f mysql-community-test_5.7.31-1ubuntu18.04_amd64.deb
2、 用dpkg进行安装
sudo dpkg -i mysql-*.deb
从图中提示我们有三个软件包未安装
sudo apt-get install libaio1
sudo apt-get install libtinfo5
sudo apt-get install libmecab2
每次安装都会提示需要运行apt --fix-broken install来修正
当三个软件包都安装过后,使用
sudo apt --fix-broken install
安装完成后会弹出下框
输入密码后确定即安装完成
使用指令进行验证
mysql -V
若能输出MySQL版本号即为安装成功