#!/bin/bash # Automatically generate a new secure password for the root user new_root_password=$(openssl rand -base64 12) # Generate random database name, user, and password for the new WordPress installation DB_NAME="wp_$(openssl rand -hex 4)" DB_USER="wp_user_$(openssl rand -hex 4)" DB_PASSWORD="$(openssl rand -base64 12)" DB_HOST="localhost" # Change if your database is hosted elsewhere echo "New root password will be: $new_root_password" echo "New WordPress database credentials:" echo "Database Name: $DB_NAME" echo "Database User: $DB_USER" echo "Database Password: $DB_PASSWORD" echo "Attempting to stop the MariaDB service..." # Stop the MariaDB service sudo systemctl stop mariadb echo "Starting MariaDB in safe mode..." # Start MariaDB in safe mode with no networking and no grants sudo mysqld_safe --skip-grant-tables --skip-networking & # Wait for MariaDB to fully start in safe mode sleep 5 echo "Resetting the root password..." # Reset the root password in safe mode sudo mysql -u root <