Skip to content

Instantly share code, notes, and snippets.

@athanasius-kircher
Created November 7, 2017 13:55
Show Gist options
  • Save athanasius-kircher/2c559a189260ce896fc392cb8f090ef0 to your computer and use it in GitHub Desktop.
Save athanasius-kircher/2c559a189260ce896fc392cb8f090ef0 to your computer and use it in GitHub Desktop.
Shell script to switch between different local Maria DB Installations
#!/bin/bash
# Creator:Julius Boellmann
# Email: jb@converia.de
brew_prefix=$(brew --prefix | sed 's#/#\\\/#g')
brew_array=("10.1" "latest")
found=0
for i in "${brew_array[@]}"
do
if [[ "$i" == "$1" ]]
then
found=1
fi
done
if ! ((found))
then
echo "Invalid argument given only following versions are supported: ${brew_array[*]} "
exit 1
fi
sudo mysql.server stop
brew unlink mariadb
brew unlink mariadb@10.1
unlink /usr/local/var/mysql
if [[ "$1" == "latest" ]]
then
brew link mariadb
else
brew link --force "mariadb@$1"
fi
ln -s "/usr/local/var/mariadb.$1/" /usr/local/var/mysql
sudo mysql.server start
@athanasius-kircher
Copy link
Author

Installation routine

Server stop and unlink is only for safety, may not be needed.

brew install mariadb
sudo mysql.server stop
brew unlink mariadb
mv /usr/local/var/mysql/ /usr/local/var/mariadb.latest
brew install mariadb@10.1
sudo mysql.server stop
brew unlink mariadb@10.1
mv /usr/local/var/mysql/ /usr/local/var/mariadb.10.1

@athanasius-kircher
Copy link
Author

Used for local contao installation due to a problem: contao/core-bundle#918

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment