(转)源码编译安装mysql 5.1
转自 :http://www.cnblogs.com/zyqduron/archive/2009/02/12/1389259.html
安装环境
本次安装MySQL的操作系统选用CentOS5.2,mysql选择5.1.31版本。由于现在的mysql被
sun收购,下载免费版本的mysql需要注册,很麻烦,直接到http://linux.softpedia.com/
搜索最新的稳定版本下载即可。
wget ftp://mirror.switch.ch/mirror/mysql/Downloads/MySQL-5.1/mysql-5.1.31.tar.gz
解压 # tar -xvzf msyql-5.1.31.tar.gz
编译安装
# ./configure --prefix=/usr/local/mysql --with-plugins=partition,innobase,myisam,ndbcluster --with-extra-charsets=complex --with-charset=utf8
# make && make install
将mysql的lib文件加载到系统变量中
# vi /etc/ld.so.conf
/usr/local/mysql/lib/mysql
# ldconfig -v | grep mysql
/usr/local/mysql/lib/mysql:
libmysqlclient.so.16 -> libmysqlclient.so.16.0.0
libmysqlclient_r.so.16 -> libmysqlclient_r.so.16.0.0
显示上面信息代表系统加载mysql的lib库正常
创建mysql用户
# useradd -s /sbin/nologin -c 'mysql user' mysql
将安装目录权限修改为mysql
# chown -R mysql.mysql /usr/local/mysql
将对应的配置文件复制到/etc/目录下
# cd /usr/local/mysql/share/mysql
# cp my-large.cnf /etc/my.cnf
编辑my.cnf文件,配置相关参数,结果如下所示:
[client]
port = 3306
socket = /home/mysql/mysql.sock
[mysqld]
port = 3306
socket = /home/mysql/mysql.sock
datadir = /home/mysql # 数据库存放目录
skip-locking
key_buffer = 256M
max_allowed_packet = 1M
table_cache = 256
sort_buffer_size = 1M
read_buffer_size = 1M
read_rnd_buffer_size = 4M
myisam_sort_buffer_size = 64M
thread_cache_size = 8
query_cache_size= 16M
thread_concurrency = 8
log-bin=/home/mysql/mysql-bin # 二进制日志文件的绝对路径
binlog-do-db=gamedb # 需要记录二进制日志的数据库
binlog_format=mixed
log-error=/home/mysql/error.log
pid-file=/home/mysql/mysql.pid
server-id = 10
[mysqldump]
quick
max_allowed_packet = 16M
[mysql]
no-auto-rehash
[isamchk]
key_buffer = 128M
sort_buffer_size = 128M
read_buffer = 2M
write_buffer = 2M
[myisamchk]
key_buffer = 128M
sort_buffer_size = 128M
read_buffer = 2M
write_buffer = 2M
[mysqlhotcopy]
interactive-timeout
生成默认数据库
# /usr/local/mysql/bin/mysql_install_db
将默认数据库的权限修改为mysql
# cd /home/
# chown -R mysql.mysql mysql
安装完毕收尾工作
# cd /usr/local/bin
# ln -s /usr/local/mysql/bin/* .
# cd /usr/local/libexec
# ln -s /usr/local/mysql/libexec/* .
# cd /usr/share/man/