以下五个软件包是在安装mysql5.5.x之前必须安装的,不然在进行cmake时会报错。这些软件可以通过下面的链接进行源码安装,也可以通过yum安装
1.安装make编译器
下载地址: http://www.gnu.org/software/make/
tar zxvf make-3.82.tar.gz
cd make-3.82
./configure
make
make install
2.安装bison
下载地址:http://www.gnu.org/software/bison/
tar zxvf bison-2.5.tar.gz
cd bison-2.5
./configure
make
make install
3.安装gcc-c++
下载地址:http://www.gnu.org/software/gcc/
tar zxvf gcc-c++-4.4.4.tar.gz
cd gcc-c++-4.4.4
./configure
make
make install
4.安装cmake
下载地址:http://www.cmake.org/
tar zxvf cmake-2.8.4.tar.gz
cd cmake-2.8.4
./configure
make
make install
MySQL从5.5版本开始,通过./configure进行编译配置方式已经被取消,取而代之的是cmake工具。
最近cmake站点发现有不能正常访问的问题,也可以通过yum进行安装
5.安装ncurses
下载地址:http://www.gnu.org/software/ncurses/
tar zxvf ncurses-5.8.tar.gz
cd ncurses-5.8
./configure
make
make install
6、开始安装MySQL,下载地址:http://dev.mysql.com/或http://www.percona.com/downloads/Percona-Server-5.5/Percona-Server-5.5.20-24.1/source/
www.percona.com下载的是一个mysql的分支版本,其要稳定性和性能上又对原mysql进行了优化。其可以完全兼容mysql并加入了优化的XtraDB存储引擎。
准备工作
groupadd mysql
useradd -r -g mysql mysql -s /sbin/nologin
tar zxvf mysql-5.5.13.tar.gz
cd mysql-5.5.13
cmake -DMYSQL_DATADIR=/opt/mysql/data
-DMYSQL_TCP_PORT=3306
-DMYSQL_UNIX_ADDR=/tmp/mysqld.sock
-DMYSQL_USER=mysql
-DDEFAULT_CHARSET=utf8
-DDEFAULT_COLLATION=utf8_general_ci
-DEXTRA_CHARSETS=all
-DWITH_READLINE=1
-DWITH_SSL=system
-DWITH_EMBEDDED_SERVER=1
-DENABLED_LOCAL_INFILE=1
-DWITH_INNOBASE_STORAGE_ENGINE=1
-DWITHOUT_PARTITION_STORAGE_ENGINE=1
make
make install
configure 与cmake参数对照指南:
http://forge.mysql.com/wiki/Autotools_to_CMake_Transition_Guide
7、配置并启动
cd /opt/mysql
chown -R mysql .
chgrp -R mysql .
scripts/mysql_install_db --user=mysql
chown -R root .
cp support-files/my-medium.cnf /etc/my.cnf
关于my.cnf的详细配置参数请查看我的另一篇日志http://www.361way.com/my-cnf/971.html
我目前在用的my.cnf配置如下:
[client]
port = 3306
socket = /tmp/mysqld.sock
[mysqld]
port = 3306
socket = /tmp/mysqld.sock
log-error = /data/mysql/logs/mysql.err
pid-file = /data/mysql/logs/mysql.pid
slow_query_log_file = /data/mysql/logs/slow.log
log = /data/mysql/logs/query_log.log
user = mysql
character-set-server = utf8
skip-character-set-client-handshake
datadir = /data/mysql/data
general_log = 1
slow_query_log = 1
core-file
max_connections = 180
key_buffer_size = 32M
max_allowed_packet = 1M
table_open_cache = 1024
tmp_table_size = 64M
max_heap_table_size = 64M
sort_buffer_size = 1M
read_buffer_size = 1M
read_rnd_buffer_size = 4M
myisam_sort_buffer_size = 16M
query_cache_type = 1
query_cache_size = 64M
query_cache_limit = 4M
thread_cache_size = 180
wait_timeout = 60
thread_concurrency = 4
log-bin=mysql-bin
binlog_format=mixed
server-id = 1
innodb_data_home_dir = /data/mysql/data
innodb_data_file_path = ibdata1:100M:autoextend
innodb_log_group_home_dir = /data/mysql/data
innodb_buffer_pool_size = 128M
innodb_additional_mem_pool_size = 10M
innodb_log_file_size = 64M
innodb_log_buffer_size = 8M
innodb_flush_log_at_trx_commit = 1
innodb_lock_wait_timeout = 50
[mysqld_safe]
character-set-server = utf8
[mysqldump]
quick
max_allowed_packet = 16M
default-character-set = utf8
[mysql]
no-auto-rehash
default-character-set = utf8
[myisamchk]
key_buffer_size = 20M
sort_buffer_size = 20M
read_buffer = 2M
write_buffer = 2M
[mysqlhotcopy]
interactive-timeout
bin/mysqld_safe --user=mysql &
#启动mysql,看是否成功
netstat -tnl|grep 3306
另外也可以通过脚本的方式启动,如下:
#将mysql的启动服务添加到系统服务中
cp support-files/mysql.server /etc/init.d/mysql.server
#现在可以使用下面的命令启动mysql
service mysql.server start
#停止mysql服务
service mysql.server stop
#重启mysql服务
service mysql.server restart
将mysql服务添加到开机启动项,让mysql服务开机启动
chkconfig --add mysql.server
完成上面的安装以后,如果还需要进行安全方面的设置请在mysql的bin目录找到脚本mysql_secure_installation,运行并按里面的提示进行安全设置。