Considerar que mysql en RHEL5 registra en un log del sistema operativo /root/.mysql_history, situacion que el dba debe evitar dentro de un entorno real de produccion.
Como acciones minimas de setup orientadas a un ambiente mysql un poco mas seguro se tienen que modificar algunos valores default:
Eliminar la base de datos test :
mysql> drop database test;
Query OK, 0 rows affected (0.00 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
+--------------------+
2 rows in set (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
+--------------------+
2 rows in set (0.00 sec)
Considerar que information_schema es algo asi como una vista de tablas, mas no neceariamente una base de datos fisica, es decir no existe debajo de /var/lib/mysql
Seleccionar base de datos mysql (base de datos por defecto), y eliminar la tabla db
mysql> use mysql;
Database changed
mysql> delete from db;
Query OK, 2 rows affected (0.00 sec)
Database changed
mysql> delete from db;
Query OK, 2 rows affected (0.00 sec)
Bien ahora miramos el contenido de la tabla user en los campos user,host y password:
mysql> select user,host,password from user;
+------+--------------------------+------------------+
| user | host | password |
+------+--------------------------+------------------+
| root | localhost | 638eb620101706b4 |
| root | server.obrasmasobras.com | |
| root | 127.0.0.1 | |
| | localhost | |
| | server.obrasmasobras.com | |
+-----+--------------------------+-----------------------------+
5 rows in set (0.00 sec)
Pues hay algunos registros inseguros, sin password por ejemplo!, por ejemplo el tercer registro dice que si yo ingreso como root@127.0.0.1 no me pedira password? a ver intentamos ..?
+------+--------------------------+------------------+
| user | host | password |
+------+--------------------------+------------------+
| root | localhost | 638eb620101706b4 |
| root | server.obrasmasobras.com | |
| root | 127.0.0.1 | |
| | localhost | |
| | server.obrasmasobras.com | |
+-----+--------------------------+-----------------------------+
5 rows in set (0.00 sec)
Pues hay algunos registros inseguros, sin password por ejemplo!, por ejemplo el tercer registro dice que si yo ingreso como root@127.0.0.1 no me pedira password? a ver intentamos ..?
[root@server ~]# mysql -u root@127.0.0.1
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 12
Server version: 5.0.77 Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 12
Server version: 5.0.77 Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>
o ..
[root@server ~]# mysql -u @localhost
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 16
Server version: 5.0.77 Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>
Caraxo... entonces debemos eliminar tales registros inseguros correcto?
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 16
Server version: 5.0.77 Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>
Caraxo... entonces debemos eliminar tales registros inseguros correcto?
mysql> delete from user where (user="" and password="");
Query OK, 2 rows affected (0.00 sec)
Query OK, 2 rows affected (0.00 sec)
mysql> delete from user where (user="root" and password="");
Query OK, 2 rows affected (0.00 sec)
Query OK, 2 rows affected (0.00 sec)
Ahora, deshabilitamos el puerto tcp con skip-networking
Finalmente, borrando algo de huellas del file system
Finalmente, borrando algo de huellas del file system
[root@server ~]# rm /root/.mysql_history
rm: remove regular file `/root/.mysql_history'? y
[root@server ~]# service mysqld restart rm: remove regular file `/root/.mysql_history'? y
Stopping MySQL: [ OK ]
Starting MySQL: [ OK ]
[root@server ~]#