Linux practical small script series (5)-the script automatically downloads the specified MySQL version from the official website

   Linux practical small script series (5)-the script automatically downloads the specified MySQL version from the official website

 Under normal circumstances, when we install MySQL, we first open the browser, enter the MySQL official website, find the download page, and select the source package or binary package or msi executable package according to the system of your machine, which is very cumbersome.

This script of mine is specifically aimed at the source installation package, that is, the version that needs to be compiled. You only need to know the exact version number. When the script is executed, the version number is used as a parameter and the script can be executed.

For example, the script name is auot_wget_mysql.sh, you need to download the source code installation package of MySQL version 5.7.19, the execution script command is:

bash auto_wget_mysql.sh  mysql-5.7.19 。

If the version you want to download is mysql 8.0.11, the script execution command is: bash auto _wget_mysql.sh mysql-8.0.11, and so on.

When the script is executed, if the number 302 is printed, it means that the version of MySQL can be downloaded. If it is not available, a prompt will be displayed. Just re-run the script and enter the correct version of MySQL.

#!/bin/bash
# auther zsk_john
input=''
echo -e "欢迎使用本脚本,请输入正确的版本号,例如 mysql-8.0.12"
URL=https://dev.mysql.com/get/Downloads/$1/$1.tar.gz
HTTP_CODE=`curl -o /dev/null -sw %{HTTP_CODE} $URL`
echo $HTTP_CODE
if [ $HTTP_CODE -eq 404 ];
then
echo "没有这个版本,请重新运行脚本,输入正确的版本号"
elif [ $HTTP_CODE -eq 302 ];
then
wget $URL
fi

 

Guess you like

Origin blog.csdn.net/alwaysbefine/article/details/108920431