#!/bin/sh # # Check if user is root # if [ $(id -u) != "0" ]; then echo "Error: You must be root to run this script, please use the root user to install the software." exit 1 fi if [ ! -f /etc/debian_version ]; then echo "Unsupported Linux Distribution. Prepared for Debian" exit 1 fi ################################################################################ # # Hostname: mariadb.dmz.lan # # IP: 192.168.50.19/24 # # OS: Debain 12 # # Container ID: 120 # # Node: PVE01 # ################################################################################ # # # ################################################################################ apt install -y mariadb-server systemctl stop mysql mkdir -p /var/log/mysql chown -R mysql:mysql /var/log/mysql mv /etc/mysql/my.cnf /etc/mysql/my.cnf.bak cat > /etc/mysql/my.cnf <<"EOF" [client] default-character-set = utf8mb4 port = 3306 socket = /var/run/mysqld/mysqld.sock [mysqld_safe] log_error=/var/log/mysql/mysql_error.log nice = 0 socket = /var/run/mysqld/mysqld.sock [mysqld] # performance_schema=ON basedir = /usr bind-address = 0.0.0.0 binlog_format = ROW character-set-server = utf8mb4 collation-server = utf8mb4_general_ci datadir = /var/lib/mysql default_storage_engine = InnoDB expire_logs_days = 2 general_log_file = /var/log/mysql/mysql.log innodb_buffer_pool_size = 2G innodb_log_buffer_size = 32M innodb_log_file_size = 512M innodb_read_only_compressed=OFF join_buffer_size = 2M key_buffer_size = 512M lc_messages_dir = /usr/share/mysql lc_messages = en_US log_bin = /var/log/mysql/mariadb-bin log_bin_index = /var/log/mysql/mariadb-bin.index log_error = /var/log/mysql/mysql_error.log log_slow_verbosity = query_plan log_warnings = 2 long_query_time = 1 max_connections = 100 max_heap_table_size = 64M myisam_sort_buffer_size = 512M port = 3306 pid-file = /var/run/mysqld/mysqld.pid query_cache_limit = 0 query_cache_size = 0 read_buffer_size = 2M read_rnd_buffer_size = 2M skip-name-resolve socket = /var/run/mysqld/mysqld.sock sort_buffer_size = 2M table_open_cache = 400 table_definition_cache = 800 tmp_table_size = 32M tmpdir = /tmp transaction_isolation = READ-COMMITTED user = mysql wait_timeout = 600 [mysqldump] max_allowed_packet = 16M quick quote-names [isamchk] key_buffer = 16M EOF systemctl restart mysql.service echo -e '\033[33m------Secure MariaDB installation-----\033[33m' echo -e "\033[0m" # master_user@mariaDB#01 mysql_secure_installation apt autoremove && apt autoclean && apt clean