当前位置: > CentOS > CentOS教程 >

Centos6.0环境中源码安装mysql5.5

时间:2016-05-30 17:29来源:linux.it.net.cn 作者:it.net.cn

本次试验环境和以往有些区别,这次用的是centos6.0的系统,安装的mysql是5.5版本的,5.0以上的版本和以前的4.0的有很大区别,第一次安装起来颇费手脚!

先安装这些包,解决依赖关系!
[root@ceshi6 ]# yum install make automake* zlib* libxml* ncurses-devel* libmcrypt* libtool* gcc*

首先需要安装cmake

[root@ceshi6 ~]# tar -zxvf cmake-2.8.7.tar.gz

[root@ceshi6 ]# cd cmake-2.8.7

[root@ceshi6 cmake-2.8.7]# ./configure

[root@ceshi6 cmake-2.8.7]# make && make install

好了,现在开始正是安装mysql5.5版本


[root@ceshi6 ~]# tar -zxvf mysql-5.5.27.tar.gz

[root@ceshi6 ~]# cd mysql-5.5.27

[root@ceshi6 mysql-5.5.27]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \ //指定mysql安装目录
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \    
-DDEFAULT_CHARSET=utf8 \   //指定服务器默认字符集,默认latin1  
-DDEFAULT_COLLATION=utf8_general_ci \  //指定服务器默认的校对规则,默认latin1_general_ci
-DWITH_EXTRA_CHARSETS:STRING=utf8,gbk \  
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DMYSQL_DATADIR=/data/mysql   // 数据文件目录

[root@ceshi6 mysql-5.5.27]# make && make install

[root@ceshi6 mysql-5.5.27]# chmod +w /usr/local/mysql/

[root@ceshi6 mysql-5.5.27]# chown -R mysql:mysql /usr/local/mysql/

[root@ceshi6 mysql-5.5.27]# ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib/libmysqlclient.so18

[root@ceshi6 mysql-5.5.27]# mkdir -p /data/mysql/data/

[root@ceshi6 mysql-5.5.27]# mkdir -p /data/mysql/log/

[root@ceshi6 mysql-5.5.27]# chown -R mysql:mysql /data/mysql/

mysql配置文件

[root@ceshi6 support-files]# cp my-large.cnf /etc/my.cnf 
cp:是否覆盖"/etc/my.cnf"? y
[root@ceshi6 support-files]# cp mysql.server /etc/init.d/mysqld 
cp:是否覆盖"/etc/init.d/mysqld"? y

初始化mysql

[root@ceshi6 support-files]# /usr/local/mysql/scripts/mysql_install_db \
> --defaults-file=/etc/my.cnf \
> --basedir=/usr/local/mysql/ \
> --datadir=/data/mysql/data/ \
> --user=mysql

[root@ceshi6 support-files]# vi /etc/init.d/mysqld

basedir=/usr/local/mysql
datadir=/data/mysql/data

[root@ceshi6 support-files]# chkconfig mysql on

[root@ceshi6 mysql-5.5.27]# mysql -u root -p

一切OK,大功告成!


 

安装过程其实没有这么顺利,在安装过程中主要的几个报错及解决方法被我记录下来了。

报错(一)

编译cmake的时候提示以下错误

[root@ceshi6 cmake-2.8.7]# ./configure 
---------------------------------------------
CMake 2.8.7, Copyright 2000-2009 Kitware, Inc.
Found GNU toolchain
C compiler on this system is: gcc 
C++ compiler on this system is: g++ 
---------------------------------------------
Error when bootstrapping CMake:
Cannot find appropriate Makefile processor on this system.
Please specify one using environment variable MAKE.
---------------------------------------------
Log of errors: /root/cmake-2.8.7/Bootstrap.cmk/cmake_bootstrap.log
---------------------------------------------

安装make,问题解决!

[root@ceshi6 cmake-2.8.7]# yum install make

报错(二)

编译安装mysql的时候提示下列错误

[root@ceshi6 mysql-5.5.27]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_EXTRA_CHARSETS:STRING=utf8,gbk \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DMYSQL_DATADIR=/data/mysql

CMake Error at cmake/readline.cmake:83 (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:118 (FIND_CURSES)
  cmake/readline.cmake:214 (MYSQL_USE_BUNDLED_READLINE)
  CMakeLists.txt:268 (MYSQL_CHECK_READLINE)


-- Configuring incomplete, errors occurred!

安装依赖包就解决了!

[root@ceshi6 mysql-5.5.27]# yum install automake* zlib* libxml* ncurses-devel* libmcrypt* libtool*

报错(三)

编译mysql的时候提示下列报错:

remove CMakeCache.txt and rerun cmake.On Debian/Ubuntu, package name is libncurses5-d

解决方法:
[root@ceshi6 mysql-5.5.27]# rm CMakeCache.txt
然后就OK了!

 



(责任编辑:IT)
------分隔线----------------------------
栏目列表
推荐内容