CentOS 5.5下LAMP环境搭建之源码安装MySQL(mysql-5.5.28)
由于安装CentOS 5.5的设置可能不一样,所以有些软件在系统安装时就顺便安装了。下面的步骤仅供参考。
mysql-5.5.28.tar.gz (http://dev.mysql.com/downloads/mysql/#downloads)
cmake-2.8.9.tar.gz (http://www.cmake.org/cmake/resources/software.html)
[root@localhost ~]# yum install gcc gcc-c++
[root@localhost src]# tar -zxf cmake-2.8.9.tar.gz [root@localhost src]# cd cmake-2.8.9 [root@localhost cmake-2.8.9]# cat Readme.txt …… * UNIX/Mac OSX/MinGW/MSYS/Cygwin: You need to have a compiler and a make installed. Run the bootstrap script you find the in the source directory of CMake. You can use the --help option to see the supported options. You may want to use the --prefix=<install_prefix> option to specify a custom installation directory for CMake. You can run the bootstrap script from within the CMake source directory or any other build directory of your choice. Once this has finished successfully, run make and make install. So basically it's the same as you may be used to from autotools-based projects: $ ./bootstrap; make; make install …… [root@localhost cmake-2.8.9]# ./bootstrap --prefix=/usr/local/cmake --------------------------------------------- CMake 2.8.9, Copyright 2000-2011 Kitware, Inc. Found GNU toolchain C compiler on this system is: gcc C++ compiler on this system is: g++ Makefile processor on this system is: gmake …… -- Could NOT find Qt4 (missing: QT_QMAKE_EXECUTABLE QT_MOC_EXECUTABLE QT_RCC_EXECUTABLE QT_UIC_EXECUTABLE QT_INCLUDE_DIR QT_LIBRARY_DIR QT_QTCORE_LIBRARY) -- Configuring done -- Generating done -- Build files have been written to: /usr/local/src/cmake-2.8.9 --------------------------------------------- CMake has bootstrapped. Now run gmake. [root@localhost cmake-2.8.9]# make && make install Scanning dependencies of target cmIML_test [ 0%] Building C object Utilities/KWIML/test/CMakeFiles/cmIML_test.dir/test.c.o [ 1%] Building C object Utilities/KWIML/test/CMakeFiles/cmIML_test.dir/test_ABI_C.c.o [ 1%] Building C object Utilities/KWIML/test/CMakeFiles/cmIML_test.dir/test_INT_C.c.o …… -- Installing: /usr/local/cmake/share/cmake-2.8/editors/vim/cmake-syntax.vim -- Installing: /usr/local/cmake/share/cmake-2.8/editors/emacs/cmake-mode.el -- Installing: /usr/local/cmake/share/cmake-2.8/completions/cmake -- Installing: /usr/local/cmake/share/cmake-2.8/completions/cpack -- Installing: /usr/local/cmake/share/cmake-2.8/completions/ctest [root@localhost cmake-2.8.9]# ln -s /usr/local/cmake/bin/cmake /usr/local/bin/cmake [root@localhost cmake-2.8.9]# cmake --version cmake version 2.8.9
[root@localhost ~]# rpm -q mysql package mysql is not installed
[root@localhost ~]# yum install ncurses-devel
[root@localhost ~]# groupadd mysql [root@localhost ~]# useradd -r -g mysql mysql [root@localhost ~]# cd /usr/local/src/ [root@localhost src]# tar -zxf mysql-5.5.28.tar.gz
[root@localhost src]# cd mysql-5.5.28 [root@localhost mysql-5.5.28]# cmake . -- The C compiler identification is GNU 4.1.2 -- The CXX compiler identification is GNU 4.1.2 …… Warning: Bison executable not found in PATH -- Configuring done -- Generating done -- Build files have been written to: /usr/local/src/mysql-5.5.28 [root@localhost mysql-5.5.28]# make Scanning dependencies of target INFO_BIN [ 0%] Built target INFO_BIN …… Linking CXX executable my_safe_process [100%] Built target my_safe_process [root@localhost mysql-5.5.28]# make install [ 0%] Built target INFO_BIN …… -- Installing: /usr/local/mysql/man/man8/mysqld.8
[root@localhost mysql-5.5.28]# cd /usr/local/mysql/ [root@localhost mysql]# chown -R mysql . [root@localhost mysql]# chgrp -R mysql . [root@localhost mysql]# scripts/mysql_install_db --user=mysql Installing MySQL system tables... OK Filling help tables... OK …… 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! [root@localhost mysql]# chown -R root . [root@localhost mysql]# chown -R mysql data [root@localhost mysql]# cp support-files/my-medium.cnf /etc/my.cnf [root@localhost mysql]# cp support-files/mysql.server /etc/init.d/mysqld
[root@localhost mysql]# bin/mysqld_safe --user=mysql & [1] 31175 [root@localhost mysql]# 121029 16:02:16 mysqld_safe Logging to '/usr/local/mysql/data/localhost.localdomain.err'. 121029 16:02:17 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
新打开一个终端,输入bin/mysql -uroot –p,如下
[root@localhost mysql]# pwd /usr/local/mysql [root@localhost mysql]# bin/mysql -uroot -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 Server version: 5.5.28-log Source distribution Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | test | +--------------------+ 4 rows in set (0.00 sec) mysql>
可见MySQL已经成功安装了!
参考资料:
1、http://dev.mysql.com/doc/refman/5.5/en/installing-source-distribution.html
2、http://dev.mysql.com/doc/refman/5.5/en/source-installation.html