最新消息:其实接手服务器,最最最重要的还是要看下数据库、文件备份情况!!!非常重要!!!

mysql 5.5编译安装

application shang 1814浏览 0评论

说明:
忘记从哪个版本开始,mysql开始采用cmake进行编译安装,所以在安装MySQL之前我们首先要把Cmake装在我们的系统。

实现:
1. 安装cmake依赖包

# yum -y install ntp vim-enhanced gcc gcc-c++ flex bison autoconf automake bzip2-devel ncurses-devel zlib-devel libjpeg-devel libpng-devel libtiff-devel freetype-devel libXpm-devel gettext-devel  pam-devel libtool libtool-ltdl openssl openssl-devel fontconfig-devel libxml2-devel curl-devel  libicu libicu-devel libmcrypt libmcrypt-devel libmhash libmhash-devel

 
2. 下载Cmake的源码包

# wget http://www.cmake.org/files/v2.8/cmake-2.8.7.tar.gz
# tar zxvf cmake-2.8.7.tar.gz
# cd cmake-2.8.7
# ./configure
# make && make install

 
3. 编译安装配置MySQL
3.1 创建用户及所需目录

# mkdir -pv /usr/local/mysql/data  //
# groupadd mysql  //创建mysql用户和mysql组
# useradd -g mysql -s /usr/sbin/nologin mysql

 
3.2 cmake编译安装

# tar zxvf mysql-5.5.22.tar.gz
# cd mysql-5.5.22
# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_unicode_ci -DWITH_READLINE=1 -DWITH_SSL=system -DWITH_EMBEDDED_SERVER=1 -DENABLED_LOCAL_INFILE=1 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_DEBUG=0
# make && make install

 
3.3 复制配置文件及设置权限

# cp support-files/my-medium.cnf /etc/my.cnf
# chmod +x /usr/local/mysql
# chown -R mysql:mysql /usr/local/mysql
# chown -R mysql:mysql /usr/local/mysql/data

 
3.4 配置启动脚本及开机自启动

# cp support-files/mysql.server /etc/init.d/mysqld
# chmod +x /etc/init.d/mysqld
# chkconfig --add mysqld
# chkconfig mysqld on

 
3.5 修改配置文件,在[mysqld]中添加

# vim /etc/my.cnf
datadir = /usr/local/mysql/data
log-error = /usr/local/mysql/data/error.log
pid-file = /usr/local/mysql/data/mysql.pid
user = mysql
tmpdir = /tmp

 
3.6 初始化数据库

# /usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data

 
3.7 手动启动MySQL

# service mysqld start

 
4. 测试MySQL是否启动,查看是否有mysql进程,查看是否有mysql端口

# ps -ef | grep mysql
# netstat -tnlp | grep 3306

 
5. 添加mysql的软链接可以使用用户直接使用

# ln -sv /usr/local/mysql/bin/mysql /usr/bin/mysql
# ln -sv /usr/local/mysql/bin/mysqladmin /usr/bin/mysqladmin
# ln -sv /usr/local/mysql/bin/mysqldump /usr/bin/mysqldump
# mysqladmin version  //获取MySQL的版本信息测试mysql,mysqladmin,mysqldump命令是否能正常使用

 
附录:
附录1:centos 5.8 编译 mysql 5.5.32时,参数-DWITH_SSL=system报错
在centos 5.8上编译mysql5.5.32,加了-DWITH_SSL=system参数,编译时报错如下,

/usr/local/src/mysql-5.5.32/vio/viossl.c: In function 'ssl_do':
/usr/local/src/mysql-5.5.32/vio/viossl.c:175: error: 'SSL_OP_NO_COMPRESSION' undeclared (first use in this function)
/usr/local/src/mysql-5.5.32/vio/viossl.c:175: error: (Each undeclared identifier is reported only once
/usr/local/src/mysql-5.5.32/vio/viossl.c:175: error: for each function it appears in.)
make[2]: *** [vio/CMakeFiles/vio.dir/viossl.c.o] Error 1
make[1]: *** [vio/CMakeFiles/vio.dir/all] Error 2
make: *** [all] Error 2

网上查了一下,应该是openssl的版本太低造成的,在centos6上编译就没有这个问题。官方已经给出了解决的patch,内容如下
— mysql-5.5.32/vio/viossl.c~2013-03-25 14:14:58.000000000 +0100
+++ mysql-5.5.32/vio/viossl.c2013-04-18 16:58:38.552557538 +0200
@@ -172,8 +172,10 @@
SSL_SESSION_set_timeout(SSL_get_session(ssl), timeout);
SSL_set_fd(ssl, vio->sd);
#ifndef HAVE_YASSL
#ifdef SSL_OP_NO_COMPRESSION
SSL_set_options(ssl, SSL_OP_NO_COMPRESSION);
#endif
#endif

if ((r= connect_accept_func(ssl)) < 1) { 意思就是说在源码的vio/viossl.c的文件中的相应位置,添加上加粗的那2行,然后重新make编译即可。

转载请注明:酷喃|coolnull| » mysql 5.5编译安装

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址