1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- #!/bin/bash
-
- # Update the system
- echo "Updating the system..."
- sudo yum update -y
-
-
- # MySQL Installation for CentOS Stream
- sudo dnf install mysql-server -y
- sudo systemctl start mysqld
- sudo systemctl enable mysqld
- MYSQL_ROOT_PASSWORD=$(sudo grep 'temporary password' /var/log/mysqld.log | tail -n 1 | awk '{print $NF}')
- echo "MySQL root temporary password: $MYSQL_ROOT_PASSWORD"
- sudo mysql_secure_installation
-
- bash elxr/mysql.init.sh
-
- # Install the MySQL repository
- # echo "Installing MySQL repository..."
- # sudo yum localinstall -y https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
-
- # # Enable the MySQL repository
- # echo "Enabling MySQL repository..."
- # sudo yum-config-manager --enable mysql80-community
-
- # # Install MySQL server
- # echo "Installing MySQL server..."
- # sudo yum install -y mysql-server
-
- # # Start MySQL service
- # echo "Starting MySQL service..."
- # sudo systemctl start mysqld
-
- # # Enable MySQL to start on boot
- # echo "Enabling MySQL to start on boot..."
- # sudo systemctl enable mysqld
-
- # # Get the temporary MySQL root password
- # TEMP_PASS=$(sudo grep 'temporary password' /var/log/mysqld.log | tail -n 1 | awk '{print $NF}')
- # echo "Temporary MySQL root password: $TEMP_PASS"
-
- # # Secure MySQL installation (you can modify the commands for automation if desired)
- # echo "Securing MySQL installation..."
- # sudo mysql_secure_installation <<EOF
-
- # y
- # $TEMP_PASS
- # newpassword
- # newpassword
- # y
- # y
- # y
- # y
- # EOF
-
-
- echo "Creating or Updating CIHSR User with remote access"
-
- # Prompt for MySQL root password
- read -sp "Enter MySQL root password: " MYSQL_PASSWORD
- echo
-
- mysql -u root -p"$MYSQL_PASSWORD" <<EOF
- CREATE USER IF NOT EXISTS 'cihsr'@'%' IDENTIFIED BY 'Cihsr@123456';
-
- GRANT ALL PRIVILEGES ON *.* TO 'cihsr'@'%' WITH GRANT OPTION;
- FLUSH PRIVILEGES;
-
- ALTER USER 'cihsr'@'%' IDENTIFIED BY 'Cihsr@123456';
- EOF
-
- if [ $? -eq 0 ]; then
- echo "User 'cihsr' has been successfully created or updated."
- else
- echo "Error: Failed to create or update user 'cihsr'."
- fi
-
- sudo firewall-cmd --zone=public --add-port=3306/tcp --permanent
- sudo firewall-cmd --reload
|