日期:2014-05-16  浏览次数:20773 次

【转载】LINUX 源码安装mysql 5.5.20
【转载】http://hi.baidu.com/suantop/blog/item/0c7689c7527428c2d0006046.html


cd /home/lxu/

wget ftp://mirror.switch.ch/mirror/mysql/Downloads/MySQL-5.5/mysql-5.5.20.tar.gz

yum -y install cmake

/usr/sbin/groupadd mysql

/usr/sbin/useradd -g mysql mysql

tar -zxvf mysql-5.5.20.tar.gz

cd mysql-5.5.20

(注:cmake安装方法,下载源码包,解压后,依次执行下面3个命令即可
./bootstrap
make
make install)


cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql  -DMYSQL_DATADIR=/usr/local/mysql/data -DEXTRA_CHARSETS=all

make

make install

cp /home/lxu/mysql-5.5.20/support-files/my-huge.cnf /usr/local/mysql/my.cnf

vi /usr/local/mysql/my.cnf

chmod +w /usr/local/mysql

chown -R mysql:mysql /usr/local/mysql

cp /home/lxu/mysql-5.5.20/support-files/mysql.server /etc/init.d/mysql

chmod +x /etc/init.d/mysql

/sbin/chkconfig --add mysql (注册mysql服务,也可以注册为mysqld)

/sbin/chkconfig mysql on (启动服务)

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

/usr/local/mysql/bin/mysqld_safe --defaults-file=/usr/local/mysql/my.cnf &

/usr/local/mysql/bin/mysqladmin -u root password 'password'

/usr/local/mysql/bin/mysqladmin -h 127.0.0.1 -ppassword version

mysql -uroot -h 127.0.0.1 -ppassword

rm -fr /etc/my.cnf



/usr/local/mysql/my.cnf 如下

[client]

port= 3306

socket= /tmp/mysql.sock

[mysqld]

port= 3306

socket= /tmp/mysql.sock

skip-external-locking

key_buffer_size = 384M

max_allowed_packet = 1M

table_open_cache = 512

sort_buffer_size = 2M

read_buffer_size = 2M

read_rnd_buffer_size = 8M

myisam_sort_buffer_size = 64M

thread_cache_size = 8

query_cache_size = 32M

thread_concurrency = 8

log-bin=mysql-bin

server-id= 1

innodb_data_home_dir = /usr/local/mysql/data

innodb_data_file_path = ibdata1:2000M;ibdata2:10M:autoextend

innodb_log_group_home_dir = /usr/local/mysql/data

innodb_buffer_pool_size = 384M

innodb_additional_mem_pool_size = 20M

innodb_log_file_size = 100M

innodb_log_buffer_size = 8M

innodb_flush_log_at_trx_commit = 1

innodb_lock_wait_timeout = 50

[mysqldump]

quick

max_allowed_packet = 16M

[mysql]

no-auto-rehash

[myisamchk]

key_buffer_size = 256M

sort_buffer_size = 256M

read_buffer = 2M

write_buffer = 2M

[mysqlhotcopy]

interactive-timeout