MySQL 5.0.90 のインストールログ 1. MySQL 用のグループとユーザの作成 /usr/sbin/groupadd mysql /usr/sbin/useradd -g mysql -d /usr/local/mysql mysql 2. ソースの展開 gtar zxvf mysql-5.0.90.tar.gz cd mysql-5.0.90 3. 作成とインストール ./configure --with-charset=eucjpms --with-extra-charsets=all --with-mysqld-user=mysql --prefix=/usr/local/mysql (mysql ユーザで実行する、インストール先は /usr/local 直下でなく /usr/local/mysql として関連ファイルをまとめる) (gcc 2.95.3 との組み合わせでは次のようなエラーがでる。 mysqld.cc: In function `void handle_segfault(int)': mysqld.cc:2279: implicit declaration of function `int localtime_r(...)' *** Error code 1 これに対処するには末尾につけた修正を include/mt_global.h に施す。) gmake gmake install (gmake を想定しているそうなので gmake を使ったが make でも大丈夫かも。) 4. データベース初期化 /usr/local/mysql5/bin/mysql_install_db --user=mysql chown -R mysql:mysql /usr/local/mysql5 (今回の設定ではデータベースは /usr/local/mysql5/var 以下に作成される) 5. 起動してみて root のパスワードを設定し、動作確認 /usr/local/mysql5/bin/mysqld_safe --user=mysql & /usr/local/mysql5/bin/mysqladmin -u root password zzzzzzzz /usr/local/mysql5/bin/mysqlshow -p (として root のパスワードを入力) または su mysql してから /usr/local/mysql5/bin/mysqlshow これで、 +----------------------+ | Databases | +----------------------+ | informational_schema | | mysql | | test | +----------------------+ と出力されればOK (起動した mysql はいったん停止) 6. 自動起動の設定 /usr/local/mysql5/share/mysql にサンプル設定ファイルがある。今回は 一般的なサーバ用の my-medium.cnf を使う (ソースを展開したディレクトリの support-files の下にも同ファイルがある) cp /usr/local/mysql5/share/mysql/my-medium.cnf /etc/my.cnf この my.cnf ファイルを編集し、[mysqld] のところに user = mysql という行を加えておく。 同様に、起動用スクリプトのサンプルをコピーする。 cp mysql.server /etc/init.d chmod 744 /etc/init.d/mysql.server cd /etc/rc3.d ln -s ../init.d/mysql.server S99mysql /etc/rc3.d/S99mysql start でうまく起動すればOK 7. データベースユーザの登録 root で mysql -p mysql (パスワードを聞かれたら入力)として mysql のコマンドモードに。 (mysql は mysql のデフォルトのユーザ管理データベース名で最初から存在する) mysql> 次に GRANT ステートメントで新規ユーザを追加する。 ここでは全権を持つ専用ユーザを登録。 (専用ユーザ名 hogehohe, パスワード xxxxxx とする) mysql> GRANT ALL PRIVILEGES ON *.* TO hogehoge@localhost IDENTIFIED BY 'xxxxxx' WITH GRANT OPTION; mysql> GRANT ALL PRIVILEGES ON *.* TO hogehoge@'%' IDENTIFIED BY 'xxxxxx' WITH GRANT OPTION; (localhost からしか接続しないなら上のステートメントだけでいいのかもしれない。 ここでのユーザは MySQL のユーザなのでホストの Solaris にユーザ登録する必要 はない) --- include/my_global.h に対するパッチ ------------------------------- [19 Apr 2006 13:08] Friedrich Haubensak Description: include/my_global.h should be modified as described below: the "Temporary solution to solve bug#7156", i.e. the inclusion of sys/types.h at this point of my_global.h, breaks the compilation of localtime_r and gmtime_r in several .cc files, at least on solaris9, using the 5.6 or 5.8 versions of sun c and sun c++ as the inclusion of sys/types.h results (a. o.) in inclusion of time.h, it has to be postponed (at least) after the #define of __EXTENSIONS__ How to repeat: try to compile on solaris 9 using SUNWspro compiler Suggested fix: --- include/my_global.h Fri Mar 31 19:10:26 2006 +++ include/my_global.h.new Wed Apr 19 11:38:58 2006 @@ -115,16 +115,8 @@ #undef _GNU_SOURCE #define _GNU_SOURCE 1 #endif -/* - Temporary solution to solve bug#7156. Include "sys/types.h" before - the thread headers, else the function madvise() will not be defined -*/ -#if defined(HAVE_SYS_TYPES_H) && ( defined(sun) || defined(__sun) ) -#include -#endif - /* The client defines this to avoid all thread code */ #if defined(UNDEF_THREADS_HACK) #undef THREAD #undef HAVE_mit_thread @@ -142,8 +134,16 @@ #ifndef __STDC_EXT__ #define __STDC_EXT__ 1 /* To get large file support on hpux */ #endif +/* + Temporary solution to solve bug#7156. Include "sys/types.h" before + the thread headers, else the function madvise() will not be defined +*/ +#if defined(HAVE_SYS_TYPES_H) && ( defined(sun) || defined(__sun) ) +#include +#endif + /* Solaris 9 include file refers to X/Open document System Interfaces and Headers, Issue 5