RHEL5下源码安装Mysql

sh# wget http://ftp.gnu.org/pub/gnu/ncurses/ncurses-5.7.tar.gz
sh# tar -zxvf ncurses-5.7.tar.gz
sh# cd ncurses-5.7
sh# ./configure --prefix=/usr/local/ncurses --with-shared --without-debug
sh# make && make install

sh# wget http://ftp.jaist.ac.jp/pub/mysql/Downloads/MySQL-5.1/mysql-5.1.45.tar.gz
sh# tar -zxvf mysql-5.1.45.tar.gz
sh# cd mysql-5.1.45
sh# groupadd mysql
sh# useradd -g mysql mysql
sh# ./configure --prefix=/usr/local/mysql \
--with-mysqld-user=mysql \
--without-debug \
--with-client-ldflags=-all-static \
--with-mysqld-ldflags=-all-static \
--disable-shared \
--localstatedir=/usr/local/mysql/data \
--with-extra-charsets=none \
--enable-assembler \
--with-unix-socket-path=/tmp/mysql.socket \
--with-named-curses-libs=/usr/local/ncurses/lib/libncurses.a
sh# make
sh# make install
sh# cp support-files/my-medium.cnf /etc/my.cnf
sh# cd /usr/local/mysql
sh# chown -R mysql .
sh# chgrp -R mysql .
sh# bin/mysql_install_db --user=mysql
sh# chown -R root .
sh# chown -R mysql data
sh# bin/mysqld_safe --user=mysql &
sh# bin/mysqladmin -u root password 'public'  //初始化密码
sh# cp support-files/mysql.server /etc/init.d/mysqld
sh# chmod +x /etc/init.d/mysqld
sh# chkconfig --add mysqld
sh# service mysqld restart

最新版的源码安装:
sh# cd /usr/local/src/mysql-5.5.16
sh# rm -f CMakeCache.txt 
sh# /usr/local/cmake/bin/cmake . \ //cmake代替configure(cmake系统自带或者另外安装./configure;gmake;gmake install),其他步骤相同
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/usr/local/mysql/data/ \
-DMYSQL_UNIX_ADDR=/tmp/mysqld.sock \
-DDEFAULT_CHARSET=utf8 \
-DEXTRA_CHARSETS=all \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DENABLED_LOCAL_INFILE=0 \
-DMYSQL_TCP_PORT=3306
sh# make
sh# make install
...

常用的my.cnf配置:
skip-external-locking
tmpdir=/home/tmp
pid-file=/tmp/mysqld.pid
skip-name-resolve  //跳过域名解析.用IP连接的可以设置该项
#skip-innodb
#skip-networking
net_buffer_length = 8K
slow-query-log-file=/usr/local/mysql/data/slow_query.log //以下三行打开慢查询.注意文件权限要对mysql用户开放
slow_query_log
long_query_time=1
log-error=/usr/local/mysql/data/error.log
#log-queries-not-using-indexes

posted @ 2012-03-30 14:48  今心  阅读(285)  评论(0编辑  收藏  举报