555
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

trias_dbserver_script.sh 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. #MYSQL SERVER INSTALLATION
  2. sudo apt update
  3. sudo apt install mysql-server
  4. sudo systemctl start mysql.service
  5. sleep 2
  6. cd /
  7. sudo mkdir mysql_backup
  8. #STEPS FOR MYSQL_SECURE_INSTALLATION
  9. #STEP-1 sudo mysql
  10. #STEP-2 ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'SET_PASSWORD';
  11. #STEP-3 exit;
  12. #STEP-4 sudo sed -i "s/.*bind-address.*/bind-address = 0.0.0.0/" /etc/mysql/mysql.conf.d/mysqld.cnf
  13. #STEP-5 sudo systemctl restart mysql
  14. #STEP-6 mysql -u root -p
  15. #STEP-7 ALTER USER 'root'@'localhost' IDENTIFIED WITH auth_socket; AND FOLLOW THE STEPS
  16. #STEP-8 exit;
  17. #STEP-9 sudo mysql_secure_installation;
  18. #STEP-10 sudo mysql;
  19. #STEP-11 mysql -u root -p
  20. #STEP-12 "ENTER MYSQL PASSWORD THAT WAS SET IN STEP 2"
  21. #STEP-13 CREATE USER '_username_'@'_desiredIP_' IDENTIFIED WITH mysql_native_password BY 'password';
  22. #STEP-14 GRANT ALL PRIVILEGES ON *.* TO '_username_'@'_desiredIP_' WITH GRANT OPTION;
  23. #STEP-15 FLUSH PRIVILEGES;
  24. echo "Please enter password for mysql: "
  25. read password
  26. sudo mysql -u root -p${password} -e "ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '${password}';"
  27. sudo sed -i "s/.*bind-address.*/bind-address = 0.0.0.0/" /etc/mysql/mysql.conf.d/mysqld.cnf
  28. sudo systemctl restart mysql
  29. echo "Please enter the IP address of app server: "
  30. read IP
  31. sudo mysql -u root -p${password} -e "CREATE USER 'root'@'${IP}' IDENTIFIED WITH mysql_native_password BY '${password}';";
  32. sudo mysql -u root -p${password} -e "GRANT ALL PRIVILEGES ON *.* TO 'root'@'${IP}' WITH GRANT OPTION;"
  33. sudo mysql -u root -p${password} -e "FLUSH PRIVILEGES;"