lpic-305-306/multivm/mariadb.sh

19 lines
732 B
Bash
Raw Permalink Normal View History

2022-05-11 17:43:53 +02:00
#!/bin/bash
#Instalacja serwera baz danych
sudo apt -y install mariadb-server mariadb-client
#Konfiguracja serwera baz danych (wykonanie m.in. "mysql_secure_installation")
sudo mysql -e "UPDATE mysql.user SET Password = PASSWORD('Zaq12wsx') WHERE User = 'root'"
sudo mysql -e "DELETE FROM mysql.user WHERE User='';"
2022-05-11 18:03:58 +02:00
sudo mysql -e "DELETE FROM mysql.user WHERE User='root' AND Host NOT IN ('localhost', '127.0.0.1', '::1', '10.10.0.2');"
2022-05-11 17:43:53 +02:00
sudo mysql -e "DROP DATABASE IF EXISTS test;"
sudo mysql -e "DELETE FROM mysql.db WHERE Db='test' OR Db='test\\_%';"
sudo mysql -e "use mysql; update user set plugin='' where User='root';"
sudo mysql -u root -e "CREATE DATABASE IF NOT EXISTS baza_test;"
sudo mysql -e "flush privileges;"