Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // To install MariaDB
- # Install dependencies
- apt install libncurses5 -y
- # Create user
- adduser --gecos --disabled-login --disabled-password --no-create-home mysql
- version=$(curl -s https://archive.mariadb.org/ | grep -oP '\d+\.\d+\.\d+' | sort -rV | head -n 1)
- wget https://archive.mariadb.org/mariadb-$version/bintar-linux-systemd-x86_64/mariadb-$version-preview-linux-systemd-x86_64.tar.gz
- if [[ ! -f mariadb-$version-preview-linux-systemd-x86_64.tar.gz ]]; then
- version=$(curl -s https://archive.mariadb.org/ | grep -oP '\d+\.\d+\.\d+' | sort -rV | head -n 1)
- wget https://archive.mariadb.org/mariadb-$version/bintar-linux-systemd-x86_64/mariadb-$version-linux-systemd-x86_64.tar.gz
- gunzip mariadb-$version-linux-systemd-x86_64.tar.gz
- tar xvf mariadb-$version-linux-systemd-x86_64.tar
- mv mariadb-$version-linux-systemd-x86_64 mariadb
- else
- gunzip mariadb-$version-preview-linux-systemd-x86_64.tar.gz
- tar xvf mariadb-$version-preview-linux-systemd-x86_64.tar
- mv mariadb-$version-preview-linux-systemd-x86_64 mariadb
- fi
- ln -fs /usr/local/mariadb/bin/* /usr/bin
- /usr/local/mariadb/scripts/mariadb-install-db --basedir=/usr/local/mariadb --datadir=/usr/local/mariadb/data
- chmod -R 777 /usr/local/mariadb
- ln -s /usr/local/mariadb /usr/local/mysql
- /usr/local/mariadb/bin/mariadbd-safe --datadir="/usr/local/mariadb/data" --pid-file="/usr/local/mariadb/data/`uname -n`.pid" "$@" &
- # Leave the question 'Enter current password for root' blank and answer the question 'Change the root password?' with 'n'
- /usr/local/mariadb/bin/mariadb-secure-installation
- ln -s /usr/local/mariadb/data/`uname -n`.err /var/log/mariadb.log
- # Now choose a username and password...
- username=
- password=
- ## You can use instead this, to let's generate a random username and password
- wget https://gist.githubusercontent.com/Justman100/239710c5764f6cae9b70a7daf042f70c/raw/a6d4802aa7e2ac1af4bb3a79ed481dd3f357b42f/grs.sh -O /usr/bin/grs
- chmod +x /usr/bin/grs
- username=$(grs 64)
- password=$(grs 64)
- mariadb << EOF
- CREATE USER $username@localhost IDENTIFIED BY '$password';
- GRANT ALL PRIVILEGES ON *.* TO $username@localhost WITH GRANT OPTION;
- CREATE USER $username IDENTIFIED BY '$password';
- GRANT ALL PRIVILEGES ON *.* TO $username WITH GRANT OPTION;
- EOF
- # Adding this to your `.bashrc` in the `/root` directory and restart your terminal
- export MYSQLCLIENT_CFLAGS="-I/usr/local/mariadb/include/mysql -I/usr/local/mariadb/include/mysql/mysql"
- export MYSQLCLIENT_LDFLAGS="-L/usr/local/mariadb/lib/ -lmariadb"
- # To get all IPs which tried to connect with the MariaDB instance
- cat /var/log/mariadb.log | grep -ioP "'.+'@'.+'" | grep -ioP '\d+\.\d+\.\d+\.\d+'
- // To uninstall MariaDB
- # Stop MariaDB
- kill $(cat /usr/local/mariadb/data/`uname -n`.pid)
- # Remove MariaDB
- rm -r /usr/local/mariadb
- # Remove binarys
- rm -r /usr/bin/aria*
- rm -r /usr/bin/garb*
- rm -r /usr/bin/galera*
- rm -r /usr/bin/innochecksum
- rm -r /usr/bin/maria*
- rm -r /usr/bin/mbstream
- rm -r /usr/bin/msql2mysql
- rm -r /usr/bin/myis*
- rm -r /usr/bin/my_print_defaults
- rm -r /usr/bin/myrocks_hotbackup
- rm -r /usr/bin/mysql*
- rm -r /usr/bin/mytop
- rm -r /usr/bin/perror
- rm -r /usr/bin/replace
- rm -r /usr/bin/resolveip
- rm -r /usr/bin/resolve_stack_dump
- rm -r /usr/bin/sst_dump
- rm -r /usr/bin/wsrep*
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement