|
@@ -487,25 +487,28 @@ establecerSQLPasswd() {
|
|
|
# Establecemos SQL root passwd y securizamos BD (mysql_secure_installation)
|
|
|
# Comprobamos si ya tiene una contraseña asignada
|
|
|
mysql -e "FLUSH PRIVILEGES" >> $logFile 2>&1
|
|
|
- comprobarError $? 206
|
|
|
- # Establecemos contraseña del usuario root
|
|
|
- mysql -e "UPDATE mysql.user SET Password = PASSWORD('$sqlPasswd') WHERE User = 'root'" >> $logFile 2>&1
|
|
|
- comprobarError $? 207
|
|
|
- # Desactivamos acceso root desde el exterior (solo localhost)
|
|
|
- mysql -e "DELETE FROM mysql.user WHERE User='root' AND Host NOT IN ('localhost', '127.0.0.1', '::1')" >> $logFile 2>&1
|
|
|
- comprobarError $? 208
|
|
|
- # Eliminamos todos los usuarios anónimos
|
|
|
- mysql -e "DELETE FROM mysql.user WHERE User=''" >> $logFile 2>&1
|
|
|
- comprobarError $? 209
|
|
|
- # Eliminamos bases de datos 'test'
|
|
|
- mysql -e "DROP DATABASE IF EXISTS test" >> $logFile 2>&1
|
|
|
- comprobarError $? 210
|
|
|
- # Eliminamos privilegios de la base de datos 'test'
|
|
|
- mysql -e "DELETE FROM mysql.db WHERE Db='test' OR Db='test\\_%'" >> $logFile 2>&1
|
|
|
- comprobarError $? 211
|
|
|
- # Aplicamos los cambios
|
|
|
- mysql -e "FLUSH PRIVILEGES" >> $logFile 2>&1
|
|
|
- comprobarError $? 212
|
|
|
+ if [ $? -eq 0 ];then
|
|
|
+ # Establecemos contraseña del usuario root
|
|
|
+ mysql -e "UPDATE mysql.user SET Password = PASSWORD('$sqlPasswd') WHERE User = 'root'" >> $logFile 2>&1
|
|
|
+ comprobarError $? 207
|
|
|
+ # Desactivamos acceso root desde el exterior (solo localhost)
|
|
|
+ mysql -e "DELETE FROM mysql.user WHERE User='root' AND Host NOT IN ('localhost', '127.0.0.1', '::1')" >> $logFile 2>&1
|
|
|
+ comprobarError $? 208
|
|
|
+ # Eliminamos todos los usuarios anónimos
|
|
|
+ mysql -e "DELETE FROM mysql.user WHERE User=''" >> $logFile 2>&1
|
|
|
+ comprobarError $? 209
|
|
|
+ # Eliminamos bases de datos 'test'
|
|
|
+ mysql -e "DROP DATABASE IF EXISTS test" >> $logFile 2>&1
|
|
|
+ comprobarError $? 210
|
|
|
+ # Eliminamos privilegios de la base de datos 'test'
|
|
|
+ mysql -e "DELETE FROM mysql.db WHERE Db='test' OR Db='test\\_%'" >> $logFile 2>&1
|
|
|
+ comprobarError $? 211
|
|
|
+ # Aplicamos los cambios
|
|
|
+ mysql -e "FLUSH PRIVILEGES" >> $logFile 2>&1
|
|
|
+ comprobarError $? 212
|
|
|
+ else
|
|
|
+ comprobarError 1 206
|
|
|
+ fi
|
|
|
}
|
|
|
|
|
|
instalarMySQL() {
|