Browse Source

mysql centos tweaks

master
jeffery 3 days ago
parent
commit
b28a7f6b89
1 changed files with 25 additions and 0 deletions
  1. 25
    0
      i.mysql.centos.sh

+ 25
- 0
i.mysql.centos.sh View File

@@ -48,3 +48,28 @@ echo "MySQL installation completed successfully."
# You can log into MySQL by running:
echo "You can log into MySQL with: mysql -u root -p"


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


Loading…
Cancel
Save