Why won't curl download this link when a browser will?
There is a redirect on the webserver-side to the following URL: http://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.16-osx10.11-x86_64.dmg
. Because it's a CDN, the exact behaviour (whether you get redirected or not) might depend on your location.
curl
does not follow redirects by default. To tell it to do so, add the -L
argument:
curl -L -O https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.16-osx10.11-x86_64.dmg
If the browser is able to download the file, you can inspect what the browser is doing. On google chrome you can use the following to see what’s happening.
1) [View > Developer > Developer tools > Network Tab > Headers tab]
2) Click on the download link.
3) The file link will appear on the developer tools tab.
4) Right click on the file and select Copy > Copy as cURL.
Now you have a curl link that will work. It will probably have excess parameters you can trim-away.
More details: https://lornajane.net/posts/2013/chrome-feature-copy-as-curl