sql_drop_tables.sh
#!/bin/bash
# Script Version: 02
# Description: Drops all tables in a specified MySQL database. If only one argument is given, the user and database name will be the same.
# Check arguments
if [ $# -lt 1 ]; then
echo "Usage: $0 <DB_USER> [DB_NAME]"
exit 1
fi
# Assign arguments
DB_USER=$1
DB_NAME=${2:-$1} # If no second argument is provided, use the first as the database name.
# Prompt for password
read -sp "Enter MySQL password: " DB_PASS
echo
# Confirmation prompt
read -p "Are you sure you want to drop all tables in $DB_NAME?mysql_create_user_db.sh
#!/bin/zsh
# Script Version: 1.1
# Description: Create MySQL Database and User (same name) with generated password
# Set variables
DBNAME=$1
PASSWORD=""
LOG_FILE="/var/log/mysql_db_user_creation.log"
# Functions
ask_for_input() {
if [ -z "$DBNAME" ]; then
read "DBNAME?Enter the database and username: "
fi
}
generate_password() {
PASSWORD=$(openssl rand -base64 12)
}
create_db_and_user() {
echo "Creating MySQL Database and User..."
mysql -u root -p <<EOF
CREATE DATABASE IF NOT EXISTS \`$DBNAME\`;
CREATE USER IF NOT EXISnginx phpMyAdmin
server {
server_name phpmyadmin.bubuit.net;
add_header Strict-Transport-Security "max-age=7200";
location / {
proxy_pass http://10.0.3.IP;
include proxy_params;
proxy_ignore_client_abort on;
auth_basic "Restricted";
auth_basic_user_file /etc/nginx/htpasswd;
}
include /etc/nginx/snippets/letsencrypt-acme-challenge.conf;
listen 80; # managed by Certbot
}- htpasswd -c /etc/nginx/htpasswd USERNAME
 
MySQL Server
- ai default-mysql-client default-mysql-server
- mysql_secure_installation
- mysqladmin -u root password 'PW'
- files
- /etc/mysql/my.cnf
- /etc/mysql/debian.cnf
- /etc/mysql/conf.d/mysqldump.cnf
- /etc/mysql/mariadb.conf.d/50-client.cnf
automysqlbackup
- ai automysqlbackup
- vim /etc/default/automysqlbackup
- BACKUPDIR="/var/backups/automysqlbackup"
- mkdir /var/backups/automysqlbackup
- /etc/cron.daily/automysqlbackup
- l /var/backups/automysqlbackup/daily/*/
- omz plugin info extract
restore
- unpack /var/backups/automysqlbackup/INTERVAL/DB-NAME/DB_INTERVAL_DATE.sql.COMPRESSION
- bzip2 -dk .sql.bz2
- gunzip .sql.gz
- extract FILE
- mysql -u root -p DB-NAME < /var/backups/automysqlbackup/INTERVAL/DB
owncloud mysql
- mysql_secure_installation
- mysql -u root -p
- create database ocdb;
- grant all on ocdb.* to ocadmin@localhost identified by "PASSWD";
- flush privileges;
- quit
apache phpMyAdmin
<VirtualHost *:80>
DocumentRoot /usr/share/phpmyadmin
ServerName phpmyadmin.bubuit.net
<Directory /usr/share/phpmyadmin>
Options SymLinksIfOwnerMatch
DirectoryIndex index.php