LINUX環境下MYSQL5.5原始碼安裝(2012年3月26日更新)

edwardking888發表於2010-12-20

首先到http://www.cmake.org/cmake/resources/software.html

cd /mysql
1.安裝cmake
1)下載cmake
#wget http://www.cmake.org/files/v2.8/cmake-2.8.7.tar.gz
2)解壓cmake
#tar -zvxf cmake-2.8.7.tar.gz
3)配置編譯
#cd cmake-2.8.7
#yum -y install gcc
#yum -y install gcc-c++
#./configure
#make
#make install

2.安裝MYSQL
1)下載MYSQL
#cd /mysql
#wget http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.21.tar.gz/from/http://mysql.mirror.rafal.ca/
2)解壓mysql-5.5.21.tar.gz
#tar -zvxf mysql-5.5.21.tar.gz

 建立資料目錄(mysql5.5預設已經沒有data目錄了)

     mkdir /mysql/mysql/data
3)配置編譯
#cd mysql-5.5.21
#cmake .                             ##這個方法,安裝路徑預設

#cmake . \
-DCMAKE_BUILD_TYPE:STRING=Release \
-DCMAKE_INSTALL_PREFIX:PATH=/mysql/mysql \
-DCOMMUNITY_BUILD:BOOL=ON \
-DENABLED_PROFILING:BOOL=ON \
-DENABLE_DEBUG_SYNC:BOOL=OFF \
-DINSTALL_LAYOUT:STRING=STANDALONE \
-DMYSQL_DATADIR:PATH=/mysql/mysql/data \
-DMYSQL_MAINTAINER_MODE:BOOL=OFF \
-DWITH_EMBEDDED_SERVER:BOOL=ON \
-DWITH_EXTRA_CHARSETS:STRING=all \
-DWITH_SSL:STRING=bundled \
-DWITH_UNIT_TESTS:BOOL=OFF \
-DWITH_ZLIB:STRING=bundled \
-LH

如果出現一下錯誤:
cmake .
-- MySQL 5.5.21
-- Could NOT find Curses (missing:  CURSES_LIBRARY CURSES_INCLUDE_PATH)
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.
Call Stack (most recent call first):
  cmake/readline.cmake:126 (FIND_CURSES)
  cmake/readline.cmake:216 (MYSQL_USE_BUNDLED_LIBEDIT)
  CMakeLists.txt:256 (MYSQL_CHECK_READLINE)


-- Configuring incomplete, errors occurred!


安裝:
# yum -y install ncurses-devel

#make

#make install

#groupadd mysql

#useradd -r -g mysql mysql

#cd /mysql/mysql
#chown -R mysql:mysql .
#scripts/mysql_install_db --user=mysql
#chown -R root .
#chown -R mysql data
#cp ./support-files/my-small.cnf ./my.cnf 
#cp support-files/mysql.server mysql; chmod +x mysql
#chown -R mysql:root .
#./mysql start
#./bin/mysqladmin -u root password

錯誤解決
1) ./scripts/mysql_install_db
      Installing MySQL system tables...
      101223 14:28:49 [ERROR] ./bin/mysqld: unknown option '--skip-locking'
      101223 14:28:49 [ERROR] Aborting
      101223 14:28:49 [Note] ./bin/mysqld: Shutdown complete
     由於是以前安裝過mysql ,所以存在/etc/my.cnf,而且mysql的環境變數和現在的不一樣,
     從而影響 現在的,解決方法是:rm -rf /etc/my.cnf

2 )  ./scripts/mysql_install_db --basedir/mysql/mysql/ --datadir/mysql/mysql/data/mysql  --user=mysql
 檢視原因:cat data/xcw.err
     101223 15:39:18 mysqld_safe Starting mysqld daemon with databases from      /w/mysqld558/data
  /w/mysqld558/bin/mysqld: Table 'mysql.plugin' doesn't exist
  101223 15:39:18 [ERROR] Can't open the mysql.plugin table. Please run  mysql_upgrade to create it.
   InnoDB: The InnoDB memory heap is disabled
   InnoDB: Mutexes and rw_locks use InnoDB's own implementation
   InnoDB: Compressed tables use zlib 1.2.3
   101223 15:39:18  InnoDB: Using Linux native AIO
   101223 15:39:18  InnoDB: Initializing buffer pool, size = 128.0M
   101223 15:39:18  InnoDB: Completed initialization of buffer pool
   101223 15:39:18  InnoDB: highest supported file format is Barracuda.
   101223 15:39:18  InnoDB: 1.1.4 started; log sequence number 1588771
   101223 15:39:18 [ERROR] //mysql/mysql/bin/mysqld: unknown option '--skip-locking'
   101223 15:39:18 [ERROR] Aborting
   原因同上,處理也同上

3)  啟動mysql服務時出現:
   Starting MySQL.The server quit without updating PID file (/w/mysqld558/xcw.pid).[FAILED]
   原因是由於data沒有設定好,解決:vi mysql : datadir=/w/mysqld558 fix to datadir=/mysql/mysql/data

大功告成!

 

 

 

 

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/8183550/viewspace-682189/,如需轉載,請註明出處,否則將追究法律責任。

相關文章