# myisampack

## myisampack

`myisampack` is a tool for compressing [MyISAM](https://github.com/mariadb-corporation/docs-server/blob/test/server/reference/storage-engines/myisam-storage-engine/README.md) tables. The resulting tables\
are read-only, and usually about 40% to 70% smaller. It is run as follows:

```
myisampack [options] file_name [file_name2...]
```

The `file_name` is the `.MYI` index file. The extension can be omitted,\
although keeping it permits wildcards, such as:

```
myisampack *.MYI
```

...to compress all the files.

`myisampack` compresses each column separately, and, when the resulting data\
is read, only the individual rows and columns required need to be decompressed,\
allowing for quicker reading.

Once a table has been packed, use [myisamchk -rq](https://mariadb.com/docs/server/clients-and-utilities/myisam-clients-and-utilities/myisamchk) (the quick\
and recover options) to rebuild its indexes.

`myisampack` does not support partitioned tables or vector indexes.

{% hint style="danger" %}
Do not run myisampack if the tables could be updated during the operation, and [skip\_external\_locking](https://mariadb.com/docs/server/server-management/variables-and-modes/server-system-variables#skip_external_locking) has been set.
{% endhint %}

### Options

The following variables can be set while passed as command line options to`myisampack`, or set with a `[myisampack]` section in your [my.cnf](https://mariadb.com/docs/server/server-management/install-and-upgrade-mariadb/configuring-mariadb/configuring-mariadb-with-option-files) file.

| Option                    | Description                                                                             |
| ------------------------- | --------------------------------------------------------------------------------------- |
| -b, --backup              | Make a backup of the table as table\_name.OLD.                                          |
| --character-sets-dir=name | Directory where character sets are.                                                     |
| -                         |                                                                                         |
| ## , --debug\[=name]      | Output debug log. Often this is 'd:t:o,filename'.                                       |
| -f, --force               | Force packing of table even if it gets bigger or if tempfile exists.                    |
| -j, --join=name           | Join all given tables into 'new\_table\_name'. All tables must have identical layouts.  |
| -?, --help                | Display help and exit.                                                                  |
| -s, --silent              | Only write output when an error occurs                                                  |
| -T, --tmpdir=name         | Use temporary directory to store temporary table.                                       |
| -t, --test                | Don't pack table, only test packing it.                                                 |
| -v, --verbose             | Write info about progress and packing result. Use multiple -v flags for more verbosity. |
| -V, --version             | Output version information and exit.                                                    |
| -w, --wait                | Wait and retry if table is in use.                                                      |

### Uncompressing

To uncompress a table compressed with `myisampack`, use the [myisamchk -u](https://mariadb.com/docs/server/clients-and-utilities/myisam-clients-and-utilities/myisamchk) option.

### Examples

```
> myisampack /var/lib/mysql/test/posts
Compressing /var/lib/mysql/test/posts.MYD: (1680 records)
- Calculating statistics
- Compressing file
37.71%
> myisamchk -rq /var/lib/mysql/test/posts
- check record delete-chain
- recovering (with sort) MyISAM-table '/var/lib/mysql/test/posts'
Data records: 1680
- Fixing index 1
- Fixing index 2
```

### See Also

* [FLUSH TABLES FOR EXPORT](https://mariadb.com/docs/server/reference/sql-statements/administrative-sql-statements/flush-commands/flush-tables-for-export)
* [myisamchk](https://mariadb.com/docs/server/clients-and-utilities/myisam-clients-and-utilities/myisamchk)

<sub>*This page is licensed: CC BY-SA / Gnu FDL*</sub>

{% @marketo/form formId="4316" %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://mariadb.com/docs/server/clients-and-utilities/myisam-clients-and-utilities/myisampack.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
