Go to the first, previous, next, last section, table of contents.


MySQL のコンパイルとインストール

MySQL を得る方法は?

MySQL の最新ニュースを読むために、いつでも MySQL のホームページ をチェックでき ます。

しかし TcX のインターネット接続はそんなに速くないので、実際には下記のミ ラーの一つからダウンロードする方が良いでしょう。

ヨーロッパ:

北アメリカ:

アジア:

オーストラリア:

どの MySQL バージョンを使うべきか?

最初の決定は、あなたが最新の開発リリースを使用したいのか、または最新の安 定リリースを使用したいのかです。

通常は、あなたが開発を開始するのなら、開発リリースで行うことを勧めます。 開発リリースには普通は本当に悪いバグはなく、あなたのマシン上で、crash-me とベンチマークテストで簡単にテストできるからです。 「MySQL benchmark suite」節参照 。

2番目の決定は、ソースを欲しいかバイナリリリースを欲しいかです。

あなたが現在バイナリリリースがあるプラットフォーム上で MySQL の 実行を望むのなら、それを使用してください。MySQL のバイナリバー ジョンの方がインストールは簡単です。

MySQL を作る C と C++ コードを読みたい(そして/または変更したい) 場合は常にソース配布を入手するべきです。コードはいつでも究極のマニュアル です。ソース配布はまたバイナリ配布よりも多くのテストと例を含んでいます。

我々の名前付けの計画を明確にします:

MySQL の全てのバージョンは、我々の標準テストと、比較的安全な使 用を保証するベンチマークを通して実行されます。標準テストは以前に見つけら れた全てのバグをテストするため、whole time は大きくなります。そのためよ り良い whole time を得ます。

MySQL リリース番号は3つの数値と拡張子からなります。

そして mysql-3.21.17-alpha-beta のようなリリース名は次の意味にな ります。

最初の数値。この場合は 3
これはファイル形式を表します。つまり全てのバージョン 3 リリースは同じファ イルフォーマットを持ちます。そしてバージョン 4 が現れた時、全てのテーブ ルは新しい形式に変換する必要があります (このための良いツールはもちろん含 まれます)。
2番目の数値。この場合は 21
これはリリースレベルです。通常は二つから選択します。一つはリリース/安定 ブランチで、もう一つは開発ブランチです。通常は両方とも安定ですが、開発バー ジョンはきまぐれで、ドキュメントがなく、いくつかのシステムではコンパイル に失敗します。
3番目の数値。この場合は 17
これはバージョン番号です。これはリリース毎に増加します。普通はあなたの選 択したリリースの最新バージョンを求めます。
拡張子。この場合は beta

全てのリリースは少なくても次のテストがされていることに注意してください:

内部テストスイート
これは顧客のための製品システムの一部です。多くのテーブルと多くのメガバイ トのデータを持っています。
MySQL ベンチマークスイート
これは一般的なクエリの範囲を実行します。これは、最適化の最新バッチが実際 にコードをより速く作れるかどうかを確認するテストでもあります。 「MySQL benchmark suite」節参照 。
crash-me テスト
これは、データベースがサポートしているものと、その制限を見つけ出そうとし ます。 「MySQL benchmark suite」節参照 。

他のテストは我々の内部製品です。我々は通常最新のバージョンを(少なくとも 一つのマシンで)このために使用し、動作のため 100Gbyte 以上のデータを持ち ます。

いつどのようにリリースを更新するのか?

我々は MySQL の更新時には次のポリシーを使用しています:

それぞれのマイナーアップデートは、バージョン文字列中の最後の数値を増加さ せます。主要な新機能や前のバージョンとのマイナーな非互換があった時には、 バージョン文字列中の2番目の数値が増加されます。ファイル形式が変更した時、 最初の数値が増加します。

MySQL がサポートする OS は?

我々は GNU autoconf を使用していますので、MySQL は POSIX スレッ ドと C++ コンパイラが動作する全ての新しいシステムに移植可能です。クライ アントコードは C++ を必要としますが、スレッドは必要ではありません。我々 は自身のソフトウェアを、最初に Sun Solaris (現在は 2.5 & 2.6) 上で、いく つかは RedHat Linux 5.0 上で使用/開発しています。

次の OS/スレッドパッケージは、MySQL のコンパイル成功が報告され ています。多くの OS では、ネイティブスレッドは最新バージョンで働くことに 注意してください。

ソースコードからの MySQL のコンパイル

必要なもの:

  1. GNU gzip。配布の伸張のため。
  2. 適当な tar。配布の展開のため。GNU tar は働くことが知られて います。
  3. ANSI C++ コンパイラ。gcc >= 2.7, SGI C++, SunPro C++ は働くことが 知られています。libg++gcc 使用時には必要ではありません。
  4. 良い make プログラム。問題があれば GNU make を試すことをお 勧めします。

素早いインストールの概要

ディレクトリ内で tar アーカイブの展開。tar ファイルは mysql-VERSION.tar.gz (VERSION は 3.21.31 のような番号です) のような名前です。mysql-VERSION という名前のディレクトリが作成されます。

zcat mysql-VERSION.tar.gz | tar xvf -
現在のディレクトリに配布を展開します。
cd mysql-VERSION
ディレクトリを変更します。
./configure
リリースを構成します。ここでいくつかのオプションを追加できます。 configure オプションの一覧は `./configure --help' を使用してくださ い。
make
全てをコンパイルします。
make install
全てをインストールします。
./scripts/mysql_install_db
MySQL 特権テーブルをセットアップします。これは MySQL を最初にインストールする時だけ必要です。データベースに接続するユーザの正 しい初期パーミッションを得るためには、このスクリプトを実行前に編集します。 「mysql_install_db 実行時の問題」節参照
'installation_directory'/bin/mysqladmin version
サーバが動いているかどうかを確認します。`./configure' にオプション を追加しない場合は、'installation_directory' は `/usr/local' です。 得られる出力の例を示します(厳密にこれが得られるわけではありません!):
mysqladmin  Ver 6.3 Distrib 3.21.17, for pc-linux-gnu on i686
TCX Datakonsult AB, by Monty

Server version          3.21.17-alpha
Protocol version        10
Connection              Localhost via UNIX socket
TCP port                3306
UNIX socket             /tmp/mysql.sock
Uptime:                 16 sec

Running threads: 1  Questions: 20  Reloads: 2  Open tables: 3

MySQL をリコンフィグした場合は、新しい configure を行う前に rm config.cache または make distclean を行う必要があること を覚えていてください。

GNU make は常に推奨され、時々は必要とされます。

有用な configure スイッチ:

警告: テーブル生成後に文字セットを変更する場合、全てのテーブルに isamchk -r -q を行う必要があります。そうしなければ、いくつかの場 合(すべてではない!)、データは不正に格納されます。

  • コンピュータ/OS 固有のスイッチについては、この章の後のメニューを見てくだ さい。

    パッチの適用

    時々メーリングリスト上にパッチが現れます。それらを適用するには次のような ことを行います:

    cd 'old-mysql-source-distribution-path'
    gunzip < patch-file-name.gz | patch -p1
    
    rm config.cache
    make clean
    

    そしてそれから通常のソースインストール指示を ./configure の段階か ら追いします。

    そしてあなたの MySQL サーバを再起動します。

    コンパイルの問題

    コンパイルが次のように失敗した場合:

    configure: error: installation or configuration problem: C++ compiler
    cannot create executables.
    

    環境変数 CXX"gcc -O3" に設定してみてください (gcc を使用している場合)。例えば CXX="gcc -O3" ./configure。 これを使用する場合、libg++ をインストールしておく必要ありません。

    g++, libg++, libstdc++ を使用して問題があった場合は、 上記の configure によっておそらくこれらをいつも解決できるでしょう!

    libg++ をインストールすることもできます。デフォルトの `configure'c++ をコンパイラ名として使用し、そして GNU c++-lg++ をリンクします。

    1. making all in mit-pthreads
      make: Fatal error in reader: Makefile, line 18: Badly formed macro assignment
      
      これは、あなたの make を GNU make にアップグレードする必要がある ことを意味します。
    2. あなたの C または C++ コンパイラにフラグを追加したい場合は、CC と CXX 環 境変数にフラグを追加してください。例えば:
      CC="gcc -O4"
      CXX="gcc -O4"
      export CC CXX
      
    3. makeCan't find Makefile.PL で止まった場合、GNU make を使用してみるべきです。Solaris と FreeBSD は厄介な make プログラムを持っていることが知られています。
    4. make からエラーメッセージを得て、エラーメッセージが次の形式の場合: pthread.h: No such file or directory これは make を GNU make にアップグレードする必要があること を意味します (GNU make versoin 3.75 は働くことが知られています)。
    5. 次のようなエラーメッセージを得る場合: client/libmysql.c:273: parse error before `__attribute__' これは gcc コンパイラ (2.7.2 は働くことが知られています) をアップグレー ドする必要があることを意味します。
    6. configure が失敗して、mysql@tcx.se にメールしようとする場合、 config.log から問題解決の助けになると考える数行を含めてください。また、 configure が異常終了する場合 configure からの出力の最後の数行も含めてく ださい。バグはスクリプト 'mysqlbug' を使用して投稿してください。 mysql@tcx.se に質問を投稿する時は 常に mysqlbug を使用してください。 「バグを見つけたと思う。私を助けるためにあなたが必要な情報は?」節参照 。 問題がバグでないとしても、mysqlbug はあなたの他の問題を解決するのを助け るようないくつかのシステム情報を収集します!
    7. mysqld または MySQL クライアントのデバッグが必要な場合、 configure を次のように実行してください: configure --with-debug=yes そしてあなたのクライアントを 新しいクライアントライブラリとリンクしてください。 クライアントを実行する前に、次を行います:
      MYSQL_DEBUG=d:t:O,/tmp/client.trace
      export MYSQL_DEBUG
      
      これでトレースファイル `/tmp/client.trace' が得られます。
    8. mysqld のコンパイル時に、次のような3つのエラーになる場合:
        cxx: Error: mysqld.cc, line 645: In this statement, the referenced type of
             the pointer value "&length" is "unsigned long", which is not compatible
             with "int".
        new_sock = accept(sock, (struct sockaddr *)&cAddr, &length);
      
      それは configure が、accept(), getsockname() そして getpeername() の最後の引数の型を決定できませんでした。次の行の後 を検索してください:
      /* Define as the base type of the last arg to accept */
      #define SOCKET_SIZE_TYPE ###
      
      そして ### を、あなたの OS に依存して size_t または int に変更してくださ い。
    9. あなたのクライアントコードに問題がある場合、バグレポートをメールする前に、 まず mysql --debug=d:t:o,/tmp/client.trace でテストしてください。 「バグを見つけたと思う。私を助けるためにあなたが必要な情報は?」節参照 。

    一般的なコンパイルの注意

    全ての MySQL プログラムは(gcc 使用の Solaris 上で)綺麗に(警告無 しで)コンパイルします。しかし異なるシステム include ファイルのため、警告 が現れることがあります。mit-pthreads 使用時に発生する警告については次を 見てください。

    sql_yacc.yy をコンパイルするためには bison を使用する必要があるでしょう。 次のようなエラーを得た場合:

    "sql_yacc.yy", line xxx fatal: default action causes potential... 
    

    bison (GNU yacc) をインストールする必要があります。MySQL は既に コンパイルされた sql_yacc.cc ファイル付きなので、通常はこれを行う必要は ありません。

    スタティックリンクされたコードを持ちたい場合、(gcc で) 次を使用します: LDFLAGS="-static" ./configure ...

    MIT-pthreads notes. (FreeBSD)

    You can on most systems force the usage of mit-pthreads with the configure switch --with-mit-threads.

    Building in a non source directory is not supported when using MIT-threads. This is because we want to keep our changes to this code minimal.

    MIT-pthreads doesn't support the AF_UNIX protocol so we must use the TCP/IP protocol for all connections (which is a little slower). If you can't connect to a table, try using the host (-h or --host) switch to mysql. This must be done if you have compiled the client code --without-server because the default connection is to use Unix sockets.

    MySQL compiled with MIT threads has system locking disabled by default for performance reasons. One can start the server with system locking with the --use-locking switch.

    Sometimes (at least on Solaris) the pthread bind() command fails to bind to a socket without any error message. The result of this is that all connections to server fails.

    > mysqladmin ver mysqladmin: connect to server at '' failed;
        error: 'Can't connect to mysql server on localhost (146)'
    

    The solution to this is to kill the mysqld daemon and restart it. This has only happened to us when we have forced the daemon down and done a restart immediately.

    sleep() isn't interruptible with SIGINT (break) with MIT-threads. This is only notable in mysqladmin --sleep. One must wait for the end of the sleep() before the interrupt is served and the process stops.

    We haven't got readline to work with MIT threads. (This isn't needed, but may be interesting for someone)

    When linking (at least on Solaris) you will receive warning messages like:

    ld: warning: symbol `_iob' has differing sizes:
    	(file /my/local/pthreads/lib/libpthread.a(findfp.o) value=0x4;
    file /usr/lib/libc.so value=0x140);
    	/my/local/pthreads/lib/libpthread.a(findfp.o) definition taken
    ld: warning: symbol `__iob' has differing sizes:
    	(file /my/local/pthreads/lib/libpthread.a(findfp.o) value=0x4;
    file /usr/lib/libc.so value=0x140);
    	/my/local/pthreads/lib/libpthread.a(findfp.o) definition taken
    

    Some other warnings which also can be ignored:

    implicit declaration of function `int strtoll(...)'
    implicit declaration of function `int strtoul(...)'
    

    Perl installation comments.

    The included perl client code requires perl5.004 or later.

    If you got a the following error (from mysqlperl or DBD-mysql):

    /usr/bin/perl: can't resolve symbol '__moddi3'
    /usr/bin/perl: can't resolve symbol '__divdi3'
    

    You are probably using gcc (or using an old binary compiled with gcc). Add -L/usr/lib/gcc-lib/... -lgcc to the link command when the mysql.so library gets build (check the output for mysql.so when you compile the perl client). -L/... is the path to the directory where libgcc.a exists.

    Another problem may be that perl and MySQL isn't both compiled with gcc. In this case you can solve this by compile everything with gcc.

    If you want to use the perl module on a system that doesn't support dynamic linking (like SCO) you can always make a static version of perl with DBI and DBD-mysql:

    First you create a statically linked DBI by doing:

    perl Makefile.PL LINKTYPE=static
    make
    make install
    make perl
    

    After this you must install the new perl. The output of make perl will contain the exact make command! On SCO this is make -f Makefile.aperl inst_perl MAP_TARGET=perl

    Next you create a statically linked DBD::mysql:

    perl Makefile.PL LINKTYPE=static
    make
    make install
    make perl
    

    You should also install the new perl (see the DBI perl installation above).

    Special things to consider for some machine/OS combinations.

    Solaris notes.

    Sun native threads only work on Solaris 2.5 and higher. For 2.4 and earlier versions, you can use MIT-pthreads. 「MIT-pthreads notes. (FreeBSD)」節参照 .

    If there are too many processes that try to connect very rapidly to the mysqld one will get Error in accept : Protocol error in the mysql log.

    If you have the Sun Workshop 4.2 compiler you can configure with: CC=cc CFLAGS="-Xa -fast -xstrconst -mt" CXX=CC CXXFLAGS="-xsb -noex -fast -mt" ./configure

    You may also have to change the row in configure:

    #if !defined(__STDC__) || __STDC__ != 1 to #if !defined(__STDC__) because if you turn on __STDC__ with the -Xc switch, the Sun compiler can't compile with the Solaris `pthread.h' header files anymore. This is a Sun bug (Broken compiler or broken include file).

    If the compiled mysqld gives a error like: libc internal error: _rmutex_unlock: rmutex not held you have tried to compile MySQL with the Sun compiler without enabling the multi thread switch -mt. Add -mt to CFLAGS and CXXFLAGS and try again.

    If you get the following error when compiling MySQL with gcc:

    gcc -O3 -g -O2 -DDBUG_OFF  -o thr_alarm ...
    ./thr_alarm.c: In function `signal_hand':
    ./thr_alarm.c:556: too many arguments to function `sigwait'
    

    This means that your gcc is not configured for your version of Solaris! The proper thing to do in this case is to get the newest egcs or gcc version and compile this with your current gcc compiler! At least for Solaris 2.5, almost all binary versions of gcc have old, unusable include files that will break all programs that use threads (and possible other programs!)

    The tar in Solaris can't handle long file names; You may get the following error (or something similar) when unpacking the MySQL distribution:

    x mysql-3.21.21a-beta-sun-solaris2.6-sparc/perl/Mysql-modules/blib/lib/auto/Msql-Mysql-modules, 0 bytes, 0 tape blocks
    tar: directory checksum error
    

    In this case you have to use gnu tar to unpack the distribution. You can find copy of precompiled gnu tar (gtar) for Solaris at http://www.mysql.com/Downloads/

    SunOS 4 notes.

    On SunOS 4, MIT-pthreads is needed. You must have GNU make to compile (because of MIT-pthreads).

    In readline you may get warnings about duplicate defines. These may be ignored.

    When compiling mysqld there will be some warnings about implicit declaration of function. These may be ignored.

    Linux notes for all versions

    On Linux you should use the --skip-locking flag to mysqld if you start it yourself. Normally the demon is started by safe_mysqld and the flag is added automatically. This flag is needed because a bug in Linux file locking calls. This bug is known to exist as recently as Linux version 2.0.33.

    If you can't start mysqld or if mysql_install_db doesn't work, please continue reading! This only happens on Linux system with problems in the Linuxthreads or libc/glibc library. There is a lot of simple workarounds to get MySQL to work! The simplest is to use the binary version (not the RPM) of MySQL for Linux x86; One nice aspect of this version is that it's probably 10% faster than any version you would compile yourself! 「MySQL の速度に影響するコンパイルとリンク方法」節参照

    When using LinuxThreads you will see a minimum of three processes running. These are in fact threads. There will be one thread for the Linux Threads manager, one thread to handle connections, and one thread to handle alarms and signals.

    if you are using RedHat you might get errors like:

    /usr/bin/perl is needed...
    /usr/sh is needed...
    /usr/sh is needed...
    

    If so upgrade rpm itself to rpm-2.4.11-1.i386.rpm & rpm-devel-2.4.11-1.i386.rpm (or later versions).

    You can get the 4.2 updates from ftp://ftp.redhat.com/updates/4.2/i386. Or http://www.sunsite.unc.edu/pub/Linux/distributions/redhat/code/rpm/ for other distributions.

    Linux-x86 notes.

    LinuxThreads should be installed before configuring MySQL!

    MySQL requires libc version 5.4.12 or newer. glibc version 2.0.6 and later should also work. There has been some problems with the glibc rpms from RedHat so if you have problems, check if there are any updates!

    On some older Linux distributions configure may give a error about: Syntax error in sched.h. Change _P to __P in the /usr/include/sched.h file.\ See the Installation chapter in the Reference Manual. Just do what the error says and add a extra underscore to the _P macro that only has one underscore. Then try again.

    You may get some warnings when compiling: (these can be ignored)

    mysqld.cc -o objs-thread/mysqld.o
    mysqld.cc: In function `void init_signals()':
    mysqld.cc:315: warning: assignment of negative value `-1' to `long unsigned int'
    mysqld.cc: In function `void * signal_hand(void *)':
    mysqld.cc:346: warning: assignment of negative value `-1' to `long unsigned int'
    

    If you want in Debian GNU/Linux to get MySQL to auto start when system boots, do the following:

    > cp scripts/mysql.server /etc/init.d/mysql.server
    > /usr/sbin/update-rc.d mysql.server defaults 99
    

    If mysqld always core dumps when starting, the problem may be that you have an old `/lib/libc.a'. Try renaming this, remove sql/mysqld and do a new make install and try again. This problem has been reported on some Slackware installations. RedHat 5.0 has also a similar problem with some new glibc versions. More about this later.

    RedHat 5.0

    If you install all the official redhat patches (including glibc-2.0.6-9 and glibc-devel-2.0.6-9) it should work out of the box (se above for how to configure).

    The updates are needed since there is a bug in glibc 2.0.5 in how pthread_key_create variables are freed. With glibc 2.0.5 you must use the static-linked MySQL binary distribution. If you want to compile from source you must install the corrected version of Linuxthreads from http://www.tcx.se/Downloads/Linux or upgrade your glibc.

    If you have a wrong glibc or linuxthread version the symptom is that mysqld crashes after each connections. For example mysqladmin version will crash mysqld when it finishes!

    Another symptom of wrong libraries is that mysqld crashes at once when it starts. One some Linux systems this can be fixed by configuring with LDFLAGS=-static ./configure. On some RedHat 5.0 system it will only work WITHOUT LDFLAGS=-static. This is known to happen even with new versions as glibc 2.0.7-4 !

    For the source distribution of glibc 2.0.7 you can find a patch at http://www.tcx.se/Download/Linux/glibc-2.0.7-total-patch.tgz that is easy to apply and is tested with MySQL!

    If you experience crashes like these when you build MySQL, you can always download the newest binary version of MySQL. This is compiled staticly to avoid library conflicts and should work on all Linux systems!

    If you want to compile this yourself, check how to debug mysqld! As MySQL comes with an internal debugger its very easy to get a trace file that probably will help solve your problem very quickly! 「MySQL のデバッグ」節参照

    Linux-Sparc notes.

    In some implementations readdir_r is broken. This will be noticed when SHOW DATABASES always returns an empty set. This can be fixed by removing HAVE_READDIR_R from `config.h'.

    Some problems will require patching your Linux installation. The patch can be found at http://www.tcx.se/patches/Linux-sparc-2.0.30.diff. This patch is against the Linux distribution `sparclinux-2.0.30.tar.gz', that is available at vger.rutgers.edu. This is a version Lf linux which was never merged with the official 2.0.30. You must also install linuxthreads 0.6 or newer.

    Thanks to jacques@solucorp.qc.ca for the above information.

    Linux-Alpha notes.

    The first problem is linuxthreads. You must patch linuxthreads for alpha because the RedHat distribution uses an old (broken) linuxthreads version.

    1. Obtain the glibc2.5c source from any GNU ftp site.
    2. Get the file ftp://www.tcx.se/pub/mysql/linux/patched-glibc-linuxthreads-0.6.tgz. This includes a fixed .c file. Copy this to the glibc `./linuxthreads' directory.
    3. Configure and compile glibc (You have to read the manual how to do this together with linuxthreads). Don't install this!
    4. Rename your old version of /usr/lib/libpthread.a to /usr/lib/libpthread.a-old
    5. Copy the file glibc.../linuxthreads/libpthread.a to /usr/lib.
    6. Configure MySQL with (everything on one row):
      CC=gcc CCFLAGS="-Dalpha_linux_port" CXX=gcc CXXFLAGS="-O3 -Dalpha_linux_port" ./configure --prefix=/usr/local/mysql
      
    7. Try to compile mysys/thr_lock and mysys/thr_alarm. Test that these work!
    8. Recompile mysqld.

    Note that Alpha-Linux is still an alpha platform for MySQL. With RedHat 5.0 and the patched linuxthreads you have a very good chance of it working.

    Alpha-DEC-Unix notes.

    When compiling threaded programs under Digital UNIX using CC / CXX the documentation recommends the switch to cc and cxx and the libraries -lmach -lexc (in addition to -lpthread).

    So you have to configure with something like this:

    CC="cc -pthread" CXX="cxx -pthread -O" ./configure -with-named-thread-libs="-lpthread -lmach -lexc -lc"

    When compiling mysqld you will may this warning for mysqld for a couple of lines:

    mysqld.cc: In function void handle_connections()':
    mysqld.cc:626: passing long unsigned int *' as argument 3 of accept(int,sockad
    ddr *, int *)'
    

    You can safely ignore these. This is because configure can't detect warnings, only errors.

    You may get problems with the server exiting directly. If so, try starting it with nohup safe_mysqld [options]

    nohup is a command that ignores any SIGHUP sent from the terminal.

    Alpha-DEC-OSF1 notes.

    If you have problems compiling and have Dec CC and gcc installed you can try the following compile line (with sh or bash):

    CC=cc CFLAGS=-O CXX=gcc CXXFLAGS=-O3 ./configure --prefix=/usr/local/mysql

    On OSF1 V4.0D and compiler "DEC C V5.6-071 on Digital UNIX V4.0 (Rev. 878)" the compiler had some strange behaviour (One gets undefined 'asm' symbols). /bin/ld appears also to be broken (one gets _exit undefined when linking mysqld). On this we have managed to compile MySQL with the following configure line, after replacing /bin/ld from OSF 4.0C:

    CC=gcc CXX=gcc CXXFLAGS=-O3 ./configure --prefix=/usr/local/mysql

    In some versions of OSF1, the alloca() functions is broken. Fix this by removing 'HAVE_ALLOCA' from config.h.

    The alloca() function can also have a wrong prototype in /usr/include/alloca.h. This warning can be ignored.

    Configure will automaticly use the following thread libraries: -with-named-thread-libs="-lpthread -lmach -lexc -lc"

    When using gcc you can also try to use:

    CFLAGS=-D_PTHREAD_USE_D4 CXX=gcc CXXFLAGS=-O3 ./configure ....

    SGI-IRIX notes.

    You may have to undefine some things in `config.h' (generated by `./configure').

    In some Irix implementations the alloca() function is broken. If the mysqld server dies on some selects, remove HAVE_ALLOC & HAVE_ALLOCA_H from `config.h'. If mysqladmin create doesn't work, remove HAVE_READDIR_R from config.h. Also you may have to remove HAVE_TERM_H.

    Irix 6.2 doesn't support POSIX threads out of of the box. You have install these patches, available from SGI if you have support:

    1403, 1404, 1644, 1717, 1918, 2000, 2044

    If you get the something like the following error when compiling mysql.cc:

    "/usr/include/curses.h", line 82: error(1084): invalid combination of type
    

    Type the following in the mysql installation directory:

    > extra/replace bool curses_bool < /usr/include/curses.h > include/curses.h
    > make
    

    There have also been reports about scheduling problems. This is because if only one thread is running, things go slow. Avoid this by starting another client. This may lead to a 2-10 fold increase in execution speed thereafter for the other thread.

    This is a poorly-understood problem with IRIS threads, so you may have to improvise to find solutions until this can be fixed.

    If you are compiling with gcc, you can use the following configure line:

    CC=gcc CXX=gcc CXXFLAGS=-O3 ./configure --prefix=/usr/local/mysql --with-thread-safe-client

    FreeBSD notes.

    If you get a error on 'make install' that it can't find /usr/include/pthreads, configure didn't detect that one neads mit-threads on FreeBSD. This is fixed by doing:

    rm config.cache
    ./configure --with-mit-threads
    

    If you get link errors when compiling mysqlperl (Type ient.a(my_getwd.o): RRS text relocation at 0x9a9f for "__db_pargs_")

    You must recompile the Perl code with -DPIC -fpic.

    Do the following:

    1. First install everything.
    2. Change in `client/Makefile' the line: CFLAGS = -g -O2 to CFLAGS = -O2 -DPIC -fpic
    3. cd client
    4. rm *.o
    5. make libmysqlclient.a
    6. cd ../perl
    7. make

    This shall hopefully be handled automatically in the future.

    The FreeBSD make behaviour is slightly different from GNU make. If you have a problem that `perl/Makefile' doesn't get generated, you should install GNU make.

    If mysql or mysqladmin takes a long time to respond, a user said the following:

    Are you running the ppp user process? On ine FreeBSD box (2.2.5) MySQL clients takes a couple of seconds to connect to mysqld if the ppp process is running.

    FreeBSD is also known to have a very low default file handle limit. 「File not found」節参照

    If you have a problem that select NOW() returns GMT and not your local time, you have to set the TZ environment variable to your current timezone.

    Make sure that you modify the /etc/hosts file so that the localhost entry is correct (else you will have problems connecting to the database).

    If you are using FreeBSD 2.2.26:

    Don't forget to apply the ttcp and mmap-22 patches to the OS (for security reasons). Please see http://www.freebsd.org for these CERT patches.

    FreeBSD-3.0 notes.

    You have to configure with:

    --with-named-thread-libs=-lc_r

    The pthreads library for FreeBSD doesn't contain the sigwait function and there is some bugs in it. To fix this, get the `FreeBSD-3.0-libc_r-1.0.diff' file and apply this in the `/usr/src/lib/libc_r/uthread' directory. Follow after this the instructions that can be found with man pthread about how to recompile the libc_r library.

    You can test if you have a 'modern' libpthread.a with:

    > nm /usr/lib/libc_r.a | grep sigwait.
    

    If the above doesn't find sigwait you have to use the above patch and recompile libc_r.

    BSD/OS 2.# notes

    From Jan Legenhausen jleg@csl-gmbh.net.

    I finally got mysqlperl working on BSDI2.1.

    What i did was almost nothing:

    1. cd client
    2. Leave the Makefile as it is! (i use GCC="shlicc2" per default; perl5 automagically uses shlicc2 - you should use _one_ version (either gcc or shlicc2) for both Mysql.c and libmysqlclient.a!)
    3. rm *.o
    4. gmake libmysqlclient.a
    5. cd ../perl/mysqlperl
    6. make clean
    7. add $sysliblist=" -L$tmp -lgcc -lcompat"; to Makefile.PL line 45 (just to be sure - i didn't check if one could leave out this one)
    8. perl Makefile.PL
    9. remove all old libmysqlclient.a's in /usr/lib and /usr/contrib/lib
    10. make install

    If you get the following error when compiling MySQL:

    item_func.h: In method `Item_func_ge::Item_func_ge(const Item_func_ge &)':
    item_func.h:28: virtual memory exhausted
    make[2]: *** [item_func.o] Error 1
    

    Then your ulimit for virtual memory is too low. Try using: ulimit -v 80000 and do make again.

    If you are using gcc you can also add the flag '-fno-inline' to the compile line when compiling sql_yacc.cc.

    If you have a problem that select NOW() returns GMT and not your local time, you have to set the TZ environment variable to your current timezone.

    BSD/OS 3.# notes.

    1. Upgrade to BSD/OS 3.1. If that is not possible, install BSDIpatch M300-038.
    2. Use the following configuration when installing MySQL:
      env CXX=shlicc++ CC=shlicc2 ./configure --prefix=/usr/local/mysql
      --localstatedir=/var/mysql --without-perl
      --with-unix-socket-path=/var/mysql/mysql.sock 
      
      The following is also known to work:
      env CC=gcc CXX=gcc CXXFLAGS=-O3 ./configure --prefix=/usr/local/mysql
      --with-unix-socket-path=/var/mysql/mysql.sock 
      
    3. If you have problems with performance under heavy load, try using the --skip-thread-prior switch to safe_mysqld! This will run all threads with the same priority and on BSDI 3.1 this gives better performance. (At least until BSDI has fixed their thread scheduler).

    You can change the directory locations if you wish, or just use their defaults by not specifying them.

    SCO notes.

    The current port is only tested on a 'sco3.2v5.0.4' system. There has also been a lot of progress on a port to 'sco 3.2v4.2'.

    1. For OpenServer 5.0.X You need to use GDS in Skunkware 95 (95q4c). This is necessary because GNU gcc 2.7.2 in Skunkware 97 does not have GNU as.
    2. You need the port of GCC 2.5.? for this product and the Developement system. They are required on this version of SCO UNIX. You can not just use the GCC Dev system.
    3. One should get FSU thread package and install this first. This can be found at: http://www.cs.wustl.edu/~schmidt/ACE_wrappers/FSU-threads.tar.gz You can also get a precompiled package from: ftp://www.tcx.se/pub/mysql/Downloads/SCO/FSU-threads-3.5c.tar.gz
    4. FSU pthreads can be compiled with SCO UNIX 4.2 with tcpip. Or OpenServer 3.0 or Open Desktop 3.0 (OS 3.0 ODT 3.0), with the SCO Developement System installed using a good port of GCC 2.5.X ODT or OS 3.0 you will need a good port of GCC 2.5.? There are a lot of problems without a good port. The port for this product requires the SCO UNIX Developement system. Without it, you are missing the libraries and the linker that is needed.
    5. To build FSU pthreads in your system do the following:
      1. Run ./configure in threads/src directory and select the SCO OpenServer option. This command copy Makefile.SCO5 to Makefile.
      2. Run make.
      3. To install in default /usr/include directory, login as root and cd to thread/src directory, run make install.
    6. Remember to use GNU make when making MySQL.
    7. If you don't start safe_mysqld as root, you will probably only get the default 110 open files per process. mysqld will write a note about this in the log file.
    8. With SCO 3.2V4.2 you must use a FSU-pthreads version 3.5c or newer. The following configure line should work:
      CFLAGS="-D_XOPEN_XPG4" CXX=gcc CXXFLAGS="-D_XOPEN_XPG4" ./configure
      --with-debug=yes --prefix=/usr/local/mysql
      --with-named-thread-libs="-lgthreads -lsocket -lgen -lgthreads"
      --with-named-curses-libs="-lcurses"
      --without-perl
      
      You may get some problems with some include files. In this case you can find new SCO specific include files at: ftp://www.tcx.se/pub/mysql/Downloads/SCO/SCO-3.2v4.2-includes.tar.gz. You should unpack this in the mysql-source-distributions/include directory!

    SCO development notes:

    IBM-AIX notes.

    When using the IBM compiler, something like this is needed:

    CC="xlc_r -ma -O3 -qstrict" CXX="xlC_r -ma -O3 -qstrict" ./configure
    

    Automatic detection of xlC is missing from autoconf.

    HPUX notes.

    There is a couple of 'small' problems when compiling mysql on HPUX. Below we describe some problems and workarounds when using the HPUX compiler and gcc 2.8.0 .

    gcc 2.8.0 can't compile readline on HPUX (internal compiler error). mit-pthreads can't be compiled with HPUX compiler, because it can't compile .S (assembler) files.

    We got MySQL to compile on HPUX 10.20 by doing the following:

    CC=cc CFLAGS="+z +e -Dhp9000s800 -D__hpux__" CXX=gcc CXXFLAGS=-O3 ./configure --prefix=/usr/local/mysql --with-low-memory
    cd mit-pthreads
    rm config.cache
    CC=gcc CXX=gcc ./configure
    cd ..
    make
    make install
    scripts/mysql_install_db
    

    Win32 notes

    The MySQL-win32 version has by now proven itself to be very stable. The MySQL-win32 version has all the features as the corresponding Unix version of MySQL with the following exceptions:

    ALTER TABLE
    One can't do a ALTER TABLE on file if it is hold open by another thread or the table cache. On MySQL-win32 I have added code to close the file owned by the thread that does ALTER TABLE but MySQL can't yet close the the file descriptors used by other threads. We have to do a major recode of the file lock system to handle this. For now, when using ALTER TABLE, one must be sure that no other threads are using the table. One can be sure of this by doing a 'mysqladmin refresh' before doing an ALTER TABLE.
    Increasing the table cache
    Win32 has only a very limited number of open files it can handle at the the same time (about 255). Because of this one shouldn't increase the number of open connections or number of cached tables very much on Win32.
    Win95 and threads
    Win95 leaks memory for each threads. Because of this one shouldn't run mysqld for an extended time on Win95 if one does many connections as each connection in MySQL creates a new thread! NT doesn't suffer from this bug.

    Other win32 specific issues are described in the README file that comes with the MySQL-win32 distribution.

    Installation instructions for MySQL binary release

    Please always use the mysqlbug script when posting questions to the mailinglist (mysql@tcx.se). Even if the problem isn't a bug, mysqlbug gathers some system information that will help other solve your problem! 「バグを見つけたと思う。私を助けるためにあなたが必要な情報は?」節参照 .

    1. Get the distribution. That is a file called something like mysql-version-OS.tgz. For example a file holding a MySQL version 3.21.15 for a intel linux machine is called `mysql-3.21.15-alpha-pc-linux-gnu-i586.tgz'.
    2. Pick a directory to put MySQL in: In the following we will use `/usr/local/mysql' as the installation directory and MySQL version VERSION (something like 3.21.15) for SunOS5 (Solaris), for example.
    3. All of the following instructions assume you have permission to create files in `/usr/local'. Use the following commands to create the directory and unpack the distribution:
      > cd /usr/local
      > zcat /<where ever you put it>/mysql-3.20.0-SunOS5.tgz | tar xvf -
      > ln -s mysql-VERSION mysql
      
    4. After this you should install the MySQL privilege tables. In some binary versions the grant tables may already be created, for others distributions you should edit the `scripts/mysql_install_db' script to have the privileges you want and run it. The default privileges is that anybody may create/use the databases named 'test' or starting with "test_". The MySQL user root can do anything. Note that you do not have to run the MySQL server as root. Any user is ok as long as it can read and write in the installtion directories/files. If you want to recreate the privilege tables remove all the *.ISM and *.ISD files in the mysql database directory, edit the scripts/mysql_install_db script to have the privileges you want and run it. This creates the privilige tables if they don't exist:
      > scripts/mysql_install_db
      
      mysql_install_db 実行時の問題」節参照 If you want to change things in the grant tables after installing you should use mysql -u root mysql to connect to the grant tables as the 'root' user. The mysql_install_db script also starts the mysqld daemon.
    5. Normally, start the MySQL server daemon (not needed the first time):
      > bin/safe_mysqld --log &
      
    6. You can test that the daemon is running by doing this:
      > bin/mysqladmin ver
      
      That should print something like this. The exact output depends on you platfrom and use.
      bin/mysqladmin  Ver 6.3 Distrib 3.21.15-alpha, for SOLARIS 2.5 on SPARCstation
      TCX Datakonsult AB, by Monty
      
      Server version          3.21.15-alpha
      Protocol version        9
      Connection              Localhost via UNIX socket
      TCP port                3306
      UNIX socket             /tmp/mysql.sock
      Uptime:                 2 days 1 hour 42 min 3 sec
      
      Running threads: 2  Questions: 450378  Reloads: 17  Open tables: 64
      

    To get perl work do the following:

    cd perl/DBI
    perl Makefile.PL
    make
    make install
    cd ../Mysql-modules
    perl Makefile.PL
    make
    make install
    

    You should use the safe_mysqld script to the server. safe_mysqld expects one of two conditions to be true:

    1. You're executing the script from the base mysql installation directory (for example /usr/local/mysql)
    2. The server should reside in /my/. To get it to run correctly, you should cd to /usr/local/mysql and then execute safe_mysqld or modify the script so that it expects the base mysql directory to be `/usr/local/mysql' rather than the default `/my/'.

    When you execute this:

    > bin/mysqld --help
    

    You will get the options for mysqld (and safe_mysqld) and the current paths. Normally you only should need to change the --basedir=path. You can test the path switches by executing:

    > bin/mysqld --basedir=/usr/local --help
    

    If you would like to use mysqlaccess and have the mysql distribution in some nonstandard place, you must change the path to mysql in mysqlaccess. bin/mysqlaccess about line 308:

    $MYSQL = '/usr/local/bin/mysql --batch --unbuffered';
    

    If you don't change the path, you will get a 'broken pipe' error when using mysqlaccess.

    If you would like MySQL to start when you boot your machine, you can copy bin/mysql.server to where your system has it startup files. More information can be bound in the bin/mysql.server script itself.

    Linux notes.

    HP/UX notes.

    The binary distribution of MySQL for HP/UX is distributed as an HP depot file. This means that you must be running at least HP/UX 10.x to have access to HP's software depot tools.

    This version of MySQL was compiled on an HP 9000/8xx server under HP/UX 10.20, and uses MIT Pthreads. It is known to work well under this configuration. This version does not use HP's native thread package. It is highly unlikely that MySQL will use HP native threads on anything but HP/UX 10.30 or later.

    Other configurations that may work:

    9000/7xx - HP/UX 10.20+ 9000/8xx - HP/UX 10.30 (does not use HP native threads)

    The following configurations almost definitely won't work:

    9000/7xx or 8xx - HP/UX 10.x where x < 2 9000/7xx or 8xx - HP/UX 9.x

    To install (everything, including server, client and development tools):

    /usr/sbin/swinstall -s <full path to the depot file> mysql.full

    To install server only:

    /usr/sbin/swinstall -s <full path to the depot file> mysql.server

    To install client pack only:

    /usr/sbin/swinstall -s <full path to the depot file> mysql.client

    To install development tools only:

    /usr/sbin/swinstall -s <full path to the depot file> mysql.developer

    The depot will place binaries/libraries in /opt/mysql and data in /var/opt/mysql. The depot will also create the appropriate entries in /sbin/init.d and /sbin/rc2.d to automatically start the server on boot. This obviously entails being root to install.

    Linking client libraries

    Clients have to be linked with: -lmysqlclient

    mysql_install_db 実行時の問題

    デフォルト特権では、だれでも test という名前、または test_ で始まる名前のデータベースを作成/使用できます。root は全てを行え ます。 「特権システムがどのように働くか?」節参照 。

    デフォルトを変更するには、そのスクリプトを実行する前に編集します。これが MySQL の初めてのインストールであれば、このコマンドを実行する必 要があります。これを行わなければ次のエラーを得るでしょう: Can't find file: './mysql/host.frm'。このスクリプトは、初回時には mysqld デー モンも開始します。

    インストール後に承認テーブル内を変更したい場合は、'root' ユーザとして承 認テーブルに接続するために mysql -u root mysql を使用してください。

    通常の MySQL サーバデーモンを開始する(初回時には必要ありません) には: 'installation_directory'/bin/safe_mysqld --log

    mysql_install_db が特権テーブルをインストールせずに、次で終わるこ とがあります:

    Starting mysql server
    starting mysqld demon with databases from xxxxxx
    mysql demon ended
    

    この場合、xxxxxx ディレクトリ内のログをかなり慎重に検査すべきです! これ は mysqld が開始しなかった理由を含んでいます。何が起こったかを理解できな い場合は、バグレポートを mysqlbug を使って投稿する時に、少なくともログを 含めるべきです。

    mysql_install_db 実行時に起こりうる問題は:

    既に動いている mysqld デーモンがある。
    この場合、mysql_install_db を実行する必要は全くありません。 mysql_install_db を実行する必要があるのは、MySQL を最初にインス トールした時だけです。
    二番目の mysqld デーモンのインストールは、他のデーモンが実行中は働かない。
    問題は、新しいサーバが古いものと同じソケットとポートを使用するように試み ることです。 次のように、異なるソケットとポートで新しいサーバを開始できます:
    MYSQL_UNIX_PORT=/tmp/mysqld-new.sock
    MYSQL_TCP_PORT=3307
    export MYSQL_UNIX_PORT MYSQL_TCP_PORT
    scripts/mysql_install_db
    
    この後、異なるソケットとポートでデーモンを開始するようにサーバのブートス クリプトを編集すべきです (safe_mysqld --socket=... --port=....)。
    mysqld が突然クラッシュする。
    RedHat 5.0 と glibc 2.0.7-5 より前のバージョンの glibc を実行する場合、 全ての glibc パッチをインストールしてあるかをチェックすべきです! MySQL メールアーカイブ中にこれについての情報が多くあります。 「Linux notes for all versions」節参照
    サーバに接続できない (mit-threads 使用時)
    mysql_install_db がサーバに接続できないときは、`/etc/hosts' ファイル中に次のようなエントリがあることをチェックすべきです:
    127.0.0.1		localhost
    
    上記はスレッドライブラリを持たないシステムで、MySQL が mit-threads を使用する必要がある時だけでの問題です。
    (/tmp に?)ソケットファイルの生成するための書き込み権がない
    この場合、mysqld を手動で開始し、自分の特権情報を追加する必要があります。 バイナリバージョンを使用していて、/usr/local/mysql にインストールしてい ない場合は、mysqld のパスを引数付きで指定すべきです。 mysqld --help で mysqld が使用するパスと変更方法についての情報を 得ることができます。次を行うことで、safe_mysqld にパスを指定することもで きます:
    MYSQL_UNIX_PATH=/some_directory_for_tmp_files/mysqld.sock
    MYSQL_TCP_PORT=3306
    TMPDIR=/some_directory_for_tmp_files/
    export MYSQL_UNIX_PATH MYSQL_TCP_PORT TMPDIR
    
    scripts/mysql_install_db
       or
    bin/mysqld --skip-grant
    
    bin/mysql -u root mysql
    
    この後、mysql_install_db 内の sql コマンドを実行できます。
    パスが mysqld が期待するものと異なる。
    コマンドライン引数で mysqld の全てのパスを上書きできます。詳細は mysqld --help を使用してください。bin/safe_mysqld を編集して、あ なたのインストールのパスを反映できます。

    全てが働くかを調べる簡単なテストは: bin/mysqladmin version

    MySQL 起動の問題

    mysqld が正常に開始したかどうかを見るには、ログファイルをチェックしてく ださい。

    mysqld デーモンは 'mysql-data-dir' へ cd して開始します。この後、 mysqld-data-dir が './' (カレントディレクトリ) に変更されます。全てのパ ス (データベース, pid ファイル, そしてログファイル) はこのディレクトリを ベースパス './' とします。何らかの正しくないパスの問題がある場合は、あな たのカレントパスを見るために mysqld --help を試して下さい。全ての パスは、safe_mysqld または mysqld への開始オプションによっ て変更できます。

    cd <localstatedir default /usr/local/var>
    tail <your host name>.log
    

    MySQL が動いていることを確かめるには、次のテストを実行してくだ さい:

    > cd /usr/local/bin
    > ./mysqlshow
    +-----------+
    | Databases |
    +-----------+
    | mysql     |
    +-----------+
    
    > ./mysqlshow mysql
    Database: mysql
    +--------+
    | Tables |
    +--------+
    | db     |
    | host   |
    | user   |
    +--------+
    
    > ./mysql -e "select host,db,user from db" mysql
    +------+--------+------+
    | host | db     | user |
    +------+--------+------+
    | %    | test   |      |
    | %    | test_% |      |
    +------+--------+------+
    

    ベンチマークスイートもあるので、異なるプラットフォーム上で MySQL 性能を比較できます。近い将来、MySQL を他の SQL データベースと比較できるようにもなります。

    > cd bench
    > run-auto-increment-test
    

    test サブディレクトリ内のテストを実行することもできます。 `auto_increment.tst' を実行するには:

    ./mysql -vf test < ./tests/auto_increment.tst
    

    期待される結果はファイル `./tests/auto_increment.res' 内に見られま す。

    safe_mysqld スクリプトは、わずかに異なるパスだったとしても、mysqld のソー スとバイナリバージョンを開始できるように書かれています!

    インストールディレクトリから safe_mysqld を開始する限り、あなたはどこに でも MySQL のバイナリリリースをインストールできます:

    cd mysql_installation_directory
    bin/safe_mysqld &
    

    mysqld の開始オプションを変更したい場合は、いつでも safe_mysqld を編集で きます! この場合、いつか MySQL のアップグレードを決めるときに safe_mysqld を上書きしないように、どこか他の場所にコピーすべきです!

    MySQL の自動起動/停止

    MySQL を起動または停止するには、次のコマンドを使用します:

    scripts/mysql.server stop
    scripts/mysql.server start
    

    MySQL を製品アプリケーションに使用するために起動する時は、この 起動と停止のコマンドを `/etc/rc*' ファイル内の適切な場所に追加しま す。固有の場所から、そして固有のユーザで safe_mysqld を開始するように mysql.server スクリプトを編集できます。またここで mysqld への開始オプショ ンを追加することもできます。


    Go to the first, previous, next, last section, table of contents.