サーバと通信する mysqlclient ライブラリを使用している全ての
MySQL クライアントは次の環境変数を使用します:
| 名前 | 説明 |
| MYSQL_UNIX_PORT | デフォルトソケット。'localhost' で使用されます。 |
| MYSQL_TCP_PORT | デフォルト TCP ポート。 |
| MYSQL_PWD | デフォルトパスワード。 |
| MYSQL_DEBUG | デバッグ時のデバッグトレースオプション。 |
| TMPDIR | 一時テーブル/ファイルが作成されるディレクトリ。 |
mysql --help を試してください。
mysql
mysql database < script.sql > output.tab で簡単にスクリプトを実行
できます。クライアントのメモリが十分でないことによる問題がある場合は、
--quick スイッチを使用してください! これは結果を取り出すのに
mysql_store_result() の代わりに mysql_use_result() を使用
するように mysql に強制させます。
mysqlaccess
mysqladmin
mysqld
mysqldump
mysqlimport
LOAD
DATA INFILE でサポートされる全ての形式を使用できます。 「LOAD DATA INFILE 構文」節参照
mysqlshow
mysqlbug
mysql_install_db
isamchk
make_binary_release
msql2mysql
mSQL プログラムを MySQL に変換するシェルスクリプト。全て
のケースで処理できるわけではありませんが、変換時に良いスタートを与えます。
replace
replace a b b a -- files は a と b を与えられたファ
イル内で交換します。
safe_mysqld
isamchk の全てのオプションは isamchk --help で得られます。
壊れたテーブルの修復のために isamchk を使用する方法についての情報: 「テーブルの修復方法」節参照 。
isamchk は -O オプションで定義した以上のメモリは使用しませ
ん。デフォルトは固定で約 2M だけを使用します。大きな値を使用することで、
isamchk をより速く動作できます。-O sortbuffer=16M の使用は多くの
場合おそらく十分です。
しかし、isamchk は TMPDIR 内に一時ファイルを使用します。
TMPDIR がメモリファイルシステムを指している場合は、簡単に out of
memory エラーを得るでしょう。
テーブルから詳細/統計を得るためには、次の方法を使用します。後でさらに詳細な情 報をいくつか説明します。
isamchk -d table_name
--skip-locking を使用する場合、
isamchk は isamchk 実行中に更新されたテーブルについてエラーを報告します
が、データ破壊の危険はありません。
isamchk -d -v table_name
isamchk -eis table_name
isamchk -eiv table_name
isamchk -d 出力の例:
ISAM file: company.ISM
Data records: 1403698 Deleted blocks: 0
Recordlength: 226
Record format: Fixed length
table description:
Key Start Len Index Type
1 2 8 unique double
2 15 10 multip. text packed stripped
3 219 8 multip. double
4 63 10 multip. text packed stripped
5 167 2 multip. unsigned short
6 177 4 multip. unsigned long
7 155 4 multip. text
8 138 4 multip. unsigned long
9 177 4 multip. unsigned long
193 1 text
isamchk -d -v 出力の例:
ISAM file: company.ISM
Isam-version: 2
Creation time: 1996-08-28 11:44:22
Recover time: 1997-01-12 18:35:29
Data records: 1403698 Deleted blocks: 0
Datafile: Parts: 1403698 Deleted data: 0
Datafilepointer (bytes): 3 Keyfile pointer (bytes): 3
Max datafile length: 3791650815 Max keyfile length: 4294967294
Recordlength: 226
Record format: Fixed length
r
table description:
Key Start Len Index Type Root Blocksize Rec/key
1 2 8 unique double 15845376 1024 1
2 15 10 multip. text packed stripped 25062400 1024 2
3 219 8 multip. double 40907776 1024 73
4 63 10 multip. text packed stripped 48097280 1024 5
5 167 2 multip. unsigned short 55200768 1024 4840
6 177 4 multip. unsigned long 65145856 1024 1346
7 155 4 multip. text 75090944 1024 4995
8 138 4 multip. unsigned long 85036032 1024 87
9 177 4 multip. unsigned long 96481280 1024 178
193 1 text
isamchk -eis 出力の例:
Checking ISAM file: company.ISM Key: 1: Keyblocks used: 97% Packed: 0% Max levels: 4 Key: 2: Keyblocks used: 98% Packed: 50% Max levels: 4 Key: 3: Keyblocks used: 97% Packed: 0% Max levels: 4 Key: 4: Keyblocks used: 99% Packed: 60% Max levels: 3 Key: 5: Keyblocks used: 99% Packed: 0% Max levels: 3 Key: 6: Keyblocks used: 99% Packed: 0% Max levels: 3 Key: 7: Keyblocks used: 99% Packed: 0% Max levels: 3 Key: 8: Keyblocks used: 99% Packed: 0% Max levels: 3 Key: 9: Keyblocks used: 98% Packed: 0% Max levels: 4 Total: Keyblocks used: 98% Packed: 17% Records: 1403698 M.recordlength: 226 Packed: 0% Recordspace used: 100% Empty space: 0% Blocks/Record: 1.00 Recordblocks: 1403698 Deleteblocks: 0 Recorddata: 317235748 Deleted data: 0 Lost space: 0 Linkdata: 0 User time 1626.51, System time 232.36 Maximum resident set size 0, Integral resident set size 0 Non physical pagefaults 0, Physical pagefaults 627, Swaps 0 Blocks in 0 out 0, Messages in 0 out 0, Signals 0 Voluntary contexts switches 639, Involuntary contexts switches 28966
isamchk -eiv 出力の例:
Checking ISAM file: company.ISM Data records: 1403698 Deleted blocks: 0 - check file-size - check delete-chain index 1: index 2: index 3: index 4: index 5: index 6: index 7: index 8: index 9: No recordlinks - check index reference - check data record references index: 1 Key: 1: Keyblocks used: 97% Packed: 0% Max levels: 4 - check data record references index: 2 Key: 2: Keyblocks used: 98% Packed: 50% Max levels: 4 - check data record references index: 3 Key: 3: Keyblocks used: 97% Packed: 0% Max levels: 4 - check data record references index: 4 Key: 4: Keyblocks used: 99% Packed: 60% Max levels: 3 - check data record references index: 5 Key: 5: Keyblocks used: 99% Packed: 0% Max levels: 3 - check data record references index: 6 Key: 6: Keyblocks used: 99% Packed: 0% Max levels: 3 - check data record references index: 7 Key: 7: Keyblocks used: 99% Packed: 0% Max levels: 3 - check data record references index: 8 Key: 8: Keyblocks used: 99% Packed: 0% Max levels: 3 - check data record references index: 9 Key: 9: Keyblocks used: 98% Packed: 0% Max levels: 4 Total: Keyblocks used: 9% Packed: 17% - check records and index references [LOTS OF ROW NUMBERS DELETED] Records: 1403698 M.recordlength: 226 Packed: 0% Recordspace used: 100% Empty space: 0% Blocks/Record: 1.00 Recordblocks: 1403698 Deleteblocks: 0 Recorddata: 317235748 Deleted data: 0 Lost space: 0 Linkdata: 0 User time 1639.63, System time 251.61 Maximum resident set size 0, Integral resident set size 0 Non physical pagefaults 0, Physical pagefaults 10580, Swaps 0 Blocks in 4 out 0, Messages in 0 out 0, Signals 0 Voluntary contexts switches 10604, Involuntary contexts switches 122798
上で使用されたテーブルのデータファイルサイズをここに示します。
-rw-rw-r-- 1 monty tcx 317235748 Jan 12 17:30 company.ISD -rw-rw-r-- 1 davida tcx 96482304 Jan 12 18:35 company.ISM
isamchk が出力するものの説明:
ISAM file
Isam-version
Creation time
Recover time
Data records
Deleted blocks
Datafile: Parts
Data records と同じです。
Deleted data
Datafile pointer
Keyfile pointer
Max datafile length
.ISD) が獲得できる長さ (バイト数)。
Max keyfile length
.ISM) が獲得できる長さ (バイト数)。
Recordlength
Record format
Fixed length を使用します。
table description
Key
Start
Len
Index
unique または multip.。このインデックス内では1つの値が複数
回存在し得ます。
Type
C データ型です。
Root
Blocksize
Rec/key
isamchk -a で更新されます。これ
が全く更新されない場合はデフォルト値の 30 が与えられます。
Keyblocks used
Packed
CHAR/VARCHAR/DECIMAL キーでだけ使用できます。名前の
ような長い文字列では、これは使用領域を顕著に減らします。上の例では4番目
のキーが10文字長で、領域の60%の減少を得ます。
Max levels
Records
M.recordlength
Packed
Recordspace used
Empty space
Blocks/Record
isamchk でテーブルを再配置
できます。 「テーブルの修復方法」節参照 。
Recordblocks
Deleteblocks
Recorddata
Deleted data
Lost space
Linkdata
pack_isam は、10 ライセンス以上または拡張サポートを注文した時に得
られる特別なものです。pack_isam はバイナリだけの配布のため、
pack_isam はいくつかのプラットフォーム上でだけに有効です。
もちろん、将来の pack_isam への更新も価格に含まれています。
pack_isam は、我々が MySQL の売上をいくらか得られた時、
標準に含まれるでしょう。
pack_isam はテーブル内の各項目を別々に圧縮するように働きます。展開のため
の情報は、テーブルがオープンされた時にメモリに読まれます。これは、正確に1レコー
ドだけを展開する必要があるような、個々のレコードへのアクセス時にとても良
い性能を与えます。MSDOS 上の Stacker 使用時のように、ディスクブロックは
そんなに大きくありません。
MySQL は圧縮されたテーブルでメモリマップ (mmap) を使用します。mmap が働かない 場合は、通常のファイルの読み書きを使用します。
通常、pack_isam はデータファイルを 40~70% にパックします。
現在 pack_isam には2つの制限があります:
これらの制限の修正は TODO にありますが、優先度は低いです。
pack_isam オプション:
> pack_isam --help
pack_isam Ver 5.0 for SOLARIS 2.5 on SPARCstation
Copyright (C) 1994-1997 TcX AB & Monty Program KB & Detron HB.
This is not free software. You must have a license to use this program
This software comes with ABSOLUTELY NO WARRANTY
Pack an ISAM-database to take much smaller space
Keys are not updated, one must run isamchk -rq on datafile afterwards
Usage: pack_isam [OPTIONS]
-b, --backup Make a backup of the table as table_name.OLD
-f, --force Force packing of table even if it's gets bigger or
tempfile exists.
-j, --join=# Join all given tables into table.
All tables MUST be identical.
-p, --packlength=# Force storage size of recordlength (1,2 or 3)
-s, --silent Be more silent.
-t, --test Don't pack table only test packing it
-v, --verbose Write info about progress and packing result
-w, --wait Wait and retry if table is in use
-T, --tmp_dir=# Use temporary directory to store temporary table
-#, --debug=... output debug log. Often this is 'd:t:o,filename`
-?, --help display this help and exit
-V, --version output version information and exit
典型的な動作:
(/my/monty/tmp) ls -l station.*
-rw-rw-r-- 1 monty my 994128 Apr 17 19:00 station.ISD
-rw-rw-r-- 1 monty my 53248 Apr 17 19:00 station.ISM
-rw-rw-r-- 1 monty my 5767 Apr 17 19:00 station.frm
(/my/monty/tmp) isamchk -dvv station
ISAM file: station
Isam-version: 2
Creation time: 1996-03-13 10:08:58
Recover time: 1997-02-02 3:06:43
Data records: 1192 Deleted blocks: 0
Datafile: Parts: 1192 Deleted data: 0
Datafilepointer (bytes): 2 Keyfile pointer (bytes): 2
Max datafile length: 54657023 Max keyfile length: 33554431
Recordlength: 834
Record format: Fixed length
table description:
Key Start Len Index Type Root Blocksize Rec/key
1 2 4 unique unsigned long 1024 1024 1
2 32 30 multip. text 10240 1024 1
column Start Length Type
1 1 1
2 2 4
3 6 4
4 10 1
5 11 20
6 31 1
7 32 30
8 62 35
9 97 35
10 132 35
11 167 4
12 171 16
13 187 35
14 222 4
15 226 16
16 242 20
17 262 20
18 282 20
19 302 30
20 332 4
21 336 4
22 340 1
23 341 8
24 349 8
25 357 8
26 365 2
27 367 2
28 369 4
29 373 4
30 377 1
31 378 2
32 380 8
33 388 4
34 392 4
35 396 4
36 400 4
37 404 1
38 405 4
39 409 4
40 413 4
41 417 4
42 421 4
43 425 4
44 429 20
45 449 30
46 479 1
47 480 1
48 481 79
49 560 79
50 639 79
51 718 79
52 797 8
53 805 1
54 806 1
55 807 20
56 827 4
57 831 4
Compressing station.ISD: (1192 records)
- Calculating statistics
normal: 20 empty-space: 16 empty-zero: 12 empty-fill: 11
pre-space: 0 end-space: 12 intervall-fields: 5 zero: 7
Original trees: 57 After join: 17
- Compressing file
87.14%
(/my/monty/tmp) ls -l station.*
-rw-rw-r-- 1 monty my 127874 Apr 17 19:00 station.ISD
-rw-rw-r-- 1 monty my 55296 Apr 17 19:04 station.ISM
-rw-rw-r-- 1 monty my 5767 Apr 17 19:00 station.frm
(my/monty/tmp) isamchk -dvv station
ISAM file: station
Isam-version: 2
Creation time: 1996-03-13 10:08:58
Recover time: 1997-04-17 19:04:26
Data records: 1192 Deleted blocks: 0
Datafile: Parts: 1192 Deleted data: 0
Datafilepointer (bytes): 3 Keyfile pointer (bytes): 1
Max datafile length: 16777215 Max keyfile length: 131071
Recordlength: 834
Record format: Compressed
table description:
Key Start Len Index Type Root Blocksize Rec/key
1 2 4 unique unsigned long 10240 1024 1
2 32 30 multip. text 54272 1024 1
Field Start Length Type Huff tree Bits
1 1 1 constant 1 0
2 2 4 zerofill(1) 2 9
3 6 4 no zeros, zerofill(1) 2 9
4 10 1 3 9
5 11 20 table-lockup 4 0
6 31 1 3 9
7 32 30 no endspace, not_always 5 9
8 62 35 no endspace, not_always, no empty 6 9
9 97 35 no empty 7 9
10 132 35 no endspace, not_always, no empty 6 9
11 167 4 zerofill(1) 2 9
12 171 16 no endspace, not_always, no empty 5 9
13 187 35 no endspace, not_always, no empty 6 9
14 222 4 zerofill(1) 2 9
15 226 16 no endspace, not_always, no empty 5 9
16 242 20 no endspace, not_always 8 9
17 262 20 no endspace, no empty 8 9
18 282 20 no endspace, no empty 5 9
19 302 30 no endspace, no empty 6 9
20 332 4 allways zero 2 9
21 336 4 allways zero 2 9
22 340 1 3 9
23 341 8 table-lockup 9 0
24 349 8 table-lockup 10 0
25 357 8 allways zero 2 9
26 365 2 2 9
27 367 2 no zeros, zerofill(1) 2 9
28 369 4 no zeros, zerofill(1) 2 9
29 373 4 table-lockup 11 0
30 377 1 3 9
31 378 2 no zeros, zerofill(1) 2 9
32 380 8 no zeros 2 9
33 388 4 allways zero 2 9
34 392 4 table-lockup 12 0
35 396 4 no zeros, zerofill(1) 13 9
36 400 4 no zeros, zerofill(1) 2 9
37 404 1 2 9
38 405 4 no zeros 2 9
39 409 4 allways zero 2 9
40 413 4 no zeros 2 9
41 417 4 allways zero 2 9
42 421 4 no zeros 2 9
43 425 4 allways zero 2 9
44 429 20 no empty 3 9
45 449 30 no empty 3 9
46 479 1 14 4
47 480 1 14 4
48 481 79 no endspace, no empty 15 9
49 560 79 no empty 2 9
50 639 79 no empty 2 9
51 718 79 no endspace 16 9
52 797 8 no empty 2 9
53 805 1 17 1
54 806 1 3 9
55 807 20 no empty 3 9
56 827 4 no zeros, zerofill(2) 2 9
57 831 4 no zeros, zerofill(1) 2 9
Go to the first, previous, next, last section, table of contents.