mysql: reparar tabla por consola / repair table from command line


Para checkear o reparar tablas de mysql por consola, debemos primero ingresar a la base de datos en cuestión:

[factura@localhost ~]$ mysql -uusuario -ppassusuario
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.0.37 Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> use dbclientes;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed

Luego, podemos hacer un check sobre una tabla específica:

mysql> check table temp_ventas;
+------------------+-------+----------+------------------------------------------------------------------------+
| Table            | Op    | Msg_type | Msg_text                                                               |
+------------------+-------+----------+------------------------------------------------------------------------+
| temp_ventas      | check | error    | Table 'temp_ventas' is marked as crashed and should be repaired        | 
+------------------+-------+----------+------------------------------------------------------------------------+
1 row in set (0.00 sec)

y con un resultado como este, realizar un repair:

mysql> repair table temp_ventas;
+------------------+--------+----------+--------------------------------------+
| Table            | Op     | Msg_type | Msg_text                             |
+------------------+--------+----------+--------------------------------------+
|      temp_ventas | repair | warning  | Number of rows changed from 13 to 14 | 
|      temp_ventas | repair | status   | OK                                   | 
+------------------+--------+----------+--------------------------------------+
2 rows in set (0.03 sec)

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s