MySQL > MySQL 5.5をソースからインストール

更新日 2011-12-25
広告
Debian (lenny)に、MySQL 5.5.8をソースからインストールする方法を紹介します。
インストールには、以下のパッケージが必要です。apt-getなどでインストールしておきましょう。
  • g++
  • cmake
  • libncurse5-dev
以下の作業は、rootユーザで行います。 まず、グループmysqlと、ユーザmysqlを作成します。
~# groupadd mysql
~# useradd -r -g mysql mysql
次にダウンロードしたソースコード mysql-5.5.8.tar.gz を解凍します。
~# tar zxvf mysql-5.5.8.tar.gz 
mysql-5.5.8というディレクトリが生成されるはずです。
ディレクトリmysql-5.5.8に移動して、cmakeを実行します。
~# cd mysql-5.5.8/
~/mysql-5.5.8# cmake .
何らかのエラーが発生して、cmakeをやり直したい場合は、以下のコマンドを実行してください。
~/mysql-5.5.8# make clean
~/mysql-5.5.8# CMakeCache.txt
cmakeが問題なく終了したら、コンパイルしてインストールします。
~/mysql-5.5.8# make
~/mysql-5.5.8# make install
MySQLが動作できるように、ディレクトリのパーミッションを設定し、mysql_install_dbを実行します。
~/mysql-5.5.8# cd /usr/local/mysql/
/usr/local/mysql# chown -R mysql .
/usr/local/mysql# chgrp -R mysql .
/usr/local/mysql# scripts/mysql_install_db --user=mysql
Installing MySQL system tables...
OK
Filling help tables...
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

./bin/mysqladmin -u root password 'new-password'
./bin/mysqladmin -u root -h cbems-weather-report password 'new-password'

Alternatively you can run:
./bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:
cd . ; ./bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd ./mysql-test ; perl mysql-test-run.pl

Please report any problems with the ./bin/mysqlbug script!
ふたたび、パーミッションの設定を行います。
/usr/local/mysql# chown -R root .
/usr/local/mysql# chown -R mysql data
設定ファイルをコピーします。 設定ファイルのテンプレートは、システム規模に応じて数種類あります。 今回は、my-large.cnfをコピーします。
/usr/local/mysql# cp support-files/my-large.cnf /etc/my.cnf
/usr/local/mysql# cp support-files/mysql.server /etc/init.d/mysql.server
以上で、インストールは終了です。 以下のコマンドで起動できます。
/usr/local/mysql# /etc/init.d/mysql.server start

g++がインストールされていないと、cmakeの実行時に以下のエラーが発生しました。
-- Check for working CXX compiler: CMAKE_CXX_COMPILER-NOTFOUND
CMake Error: your CXX compiler: "CMAKE_CXX_COMPILER-NOTFOUND" was not found.   Please set CMAKE_CXX_COMPILER to a valid compiler path or name.
CMake Error: Internal CMake error, TryCompile configure of cmake failed
-- Check for working CXX compiler: CMAKE_CXX_COMPILER-NOTFOUND -- broken
CMake Error at /usr/share/cmake-2.6/Modules/CMakeTestCXXCompiler.cmake:25 (MESSAGE):
  The C++ compiler "CMAKE_CXX_COMPILER-NOTFOUND" is not able to compile a
  simple test program.
libncurse5-devがインストールされていないと、cmake実行時に以下のエラーが発生しました。
-- Could NOT find Curses
CMake Error at cmake/readline.cmake:82 (MESSAGE):
  Curses library not found.  Please install appropriate package,

      remove CMakeCache.txt and rerun cmake.On Debian/Ubuntu, package name is libncurses5-dev, on Redhat and derivates it is ncurses-devel.
広告
お問い合わせは sweng.tips@gmail.com まで。
inserted by FC2 system