1.查看是否有安装其他版本文件
find / -name mysql
2.查看系统版本号
uname -a
3.下载指定版本
方法一: 官网地址 https://dev.mysql.com/downloads/mysql/
点击Archives 选择需要的指定版本并进行下载, 本文以 mysql-server_5.7.37-1ubuntu18.04_amd64.deb-bundle.tar 为例;
使用xftp或者拖动上传到Linux服务器
解压:
tar xvf mysql-server_5.7.37-1ubuntu18.04_amd64.deb-bundle.tar
查看:
root@ecs-df00:/home/dev# ll total 313300 drwxr-xr-x 2 root root 4096 Jul 10 23:35 ./ drwxr-xr-x 3 root root 4096 Jul 10 23:20 ../ -rw-r--r-- 1 7155 31415 1593760 Nov 30 2021 libmysqlclient20_5.7.37-1ubuntu18.04_amd64.deb -rw-r--r-- 1 7155 31415 2177992 Nov 30 2021 libmysqlclient-dev_5.7.37-1ubuntu18.04_amd64.deb -rw-r--r-- 1 7155 31415 19471792 Nov 30 2021 libmysqld-dev_5.7.37-1ubuntu18.04_amd64.deb -rw-r--r-- 1 7155 31415 70260 Nov 30 2021 mysql-client_5.7.37-1ubuntu18.04_amd64.deb -rw-r--r-- 1 7155 31415 73640 Nov 30 2021 mysql-common_5.7.37-1ubuntu18.04_amd64.deb -rw-r--r-- 1 7155 31415 14600008 Nov 30 2021 mysql-community-client_5.7.37-1ubuntu18.04_amd64.deb -rw-r--r-- 1 7155 31415 36535784 Nov 30 2021 mysql-community-server_5.7.37-1ubuntu18.04_amd64.deb -rw-r--r-- 1 7155 31415 53200520 Nov 30 2021 mysql-community-source_5.7.37-1ubuntu18.04_amd64.deb -rw-r--r-- 1 7155 31415 32520592 Nov 30 2021 mysql-community-test_5.7.37-1ubuntu18.04_amd64.deb -rw-r--r-- 1 7155 31415 70256 Nov 30 2021 mysql-server_5.7.37-1ubuntu18.04_amd64.deb -rw-r--r-- 1 root root 160399360 Jul 10 23:25 mysql-server_5.7.37-1ubuntu18.04_amd64.deb-bundle.tar -rw-r--r-- 1 7155 31415 70268 Nov 30 2021 mysql-testsuite_5.7.37-1ubuntu18.04_amd64.deb
使用 dpkg -i 解压对应 deb包:
dpkg -i mysql-{common,community-client,client,community-server,server}_*.deb
4. 登录验证:
启动服务
systemctl start mysqld
root@ecs-df00:/home/dev# mysql -u root -p mysql: error while loading shared libraries: libtinfo.so.5: cannot open shared object file: No such file or directory
安装 libncurses5 解决
sudo apt-get install libncurses5
root@ecs-df00:/usr/lib64# mysql -u root -p Enter password:
其中,mysql默认安装到 /etc/mysql 目录中