CentOS 5.5 编译安装mysql 5.5.18[转]

利用CentOS Linux系统自带的yum命令安装、升级所需的程序库(RedHat等其他Linux发行版可从安装光盘中找到这些程序库的RPM包,进行安装):

sudo -s
LANG=C
yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel \
freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel \
glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel \
curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel \
libidn libidn-devel openssl openssl-devel \
openldap openldap-devel nss_ldap \
openldap-clients openldap-servers

#先下载cmake

wget http://www.cmake.org/files/v2.8/cmake-2.8.4.tar.gz

#安装cmake
tar xvzf cmake-2.8.4.tar.gz
./configure
make
make install

#创建mysql用户名及组
/usr/sbin/groupadd mysql
/usr/sbin/useradd -g mysql mysql
#下载最新的mysql
wget ftp://mirror.switch.ch/mirror/mysql/Downloads/MySQL-5.5/mysql-5.5.18.tar.gz
#解压
tar zxvf mysql-5.5.18.tar.gz
cd mysql-5.5.18
#开始编译并安装

/usr/local/bin/cmake
-DCMAKE_INSTALL_PREFIX=/usr/local/webserver/mysql \
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_EXTRA_CHARSETS:STRING=utf8,gbk,gb2312 \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DMYSQL_DATADIR=/var/mysql/data \
-DMYSQL_USER=mysql -DWITH_DEBUG=0 \

make && make install
chmod +w /usr/local/webserver/mysql
chown -R mysql:mysql /usr/local/webserver/mysql
cp support-files/my-small.cnf /etc/my.cnf
chown mysql:mysql /etc/my.cnf
cp mysql.server /etc/rc.d/init.d/mysqld

执行下面的
/usr/local/webserver/mysql/scripts/mysql_install_db \
–user=mysql \
–basedir=/usr/local/webserver/mysql \
–datadir=/var/mysql/data

vi /etc/init.d/mysqld
#编辑此文件,查找并修改以下变量内容:
basedir=/usr/local/mysql
datadir=/var/mysql/data

chkconfig –add mysqld
chkconfig –level 345 mysqld on

在/etc/my.cnf 打开下面的InnoDB配置以减少内存即可:
default-storage-engine=MyISAM
server-id = 1
innodb_buffer_pool_size = 21M
innodb_additional_mem_pool_size = 2M
innodb_log_file_size = 5M
innodb_log_buffer_size = 8M
innodb_flush_log_at_trx_commit = 1
innodb_lock_wait_timeout = 50

启动:
service mysqld start
#修改密码
/usr/local/webserver/mysql/bin/mysqladmin -u root password newpassword

转自:http://www.cnblogs.com/fangbo/archive/2011/04/01/2002637.html

发表评论

电子邮件地址不会被公开。 必填项已用 * 标注


*

您可以使用这些 HTML 标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>