[root@Mysql-server tools]# yum install -y ncurses-devel libaio-devel
[root@Mysql-server tools]# rpm -qa ncurses-devel libaio-devel
ncurses-devel-5.7-4.20090207.el6.x86_64
libaio-devel-0.3.107-10.el6.x86_64
[root@Mysql-server tools]# tar xf cmake-2.8.8.tar.gz
[root@Mysql-server tools]# cd cmake-2.8.8
[root@Mysql-server cmake-2.8.8]#./configure
[root@mysql cmake-2.8.8]# gmake
[root@mysql cmake-2.8.8]# gmake install
[root@mysql tools]# useradd mysql -s /sbin/nologin -M
[root@mysql tools]# id mysql
uid=501(mysql) gid=501(mysql) 组=501(mysql)
[root@mysql tools]#
tar zxf mysql-5.5.32.tar.gz
cd mysql-5.5.32
cmake .-DCMAKE_INSTALL_PREFIX=/application/mysql-5.5.32 \
-DMYSQL_DATADIR=/application/mysql-5.5.32/data \
-DMYSQL_UNIX_ADDR=/application/mysql-5.5.32/tmp/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DEXTRA_CHARSETS=gbk,gb2312,utf8,ascii \
-DENABLED_LOCAL_INFILE=ON \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 \
-DWITHOUT_PARTITION_STORAGE_ENGINE=1 \
-DWITH_FAST_MUTEXES=1 \
-DWITH_ZLIB=bundled \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_READLINE=1 \
-DWITH_EMBEDDED_SERVER=1 \
-DWITH_DEBUG=0
#-- Build files have been written to: /home/oldboy/tools/mysql-5.5.32
提示,编译时可配置的选项很多,具体可参考结尾附录或官方文档:
make
#[100%] Built target my_safe_process
make install
ln -s /application/mysql-5.5.32//application/mysql
如果上述操作未出现错误,则MySQL5.5.32软件cmake方式的安装就算成功了。
[root@mysql mysql-5.5.32]# rm CMakeCache.txt ###删除这个文件,重新cmake
[root@mysql mysql-5.5.32]# mkdir -p /data/{3306,3307}/data
[root@mysql mysql-5.5.32]# tree /data/
/data/
├──3306
│??└── data ##实例3306的数据文件
├──3307
│??└── data ##实例3307的数据文件
└── test
[root@mysql /]# unzip data.zip ##上传到根下,加压会替换上面创建的/data目录
Archive: data.zip
inflating: data/3306/my.cnf
inflating: data/3306/mysql
inflating: data/3307/my.cnf
inflating: data/3307/mysql
[root@mysql /]# tree /data
data/ data.zip
[root@mysql /]# tree data
data/ data.zip
[root@mysql /]# tree data/
data/
├──3306
│??├── data
│??├── my.cnf ##实例的配置文件
│??└── mysql ##实例的启动文件
├──3307
│??├── data
│??├── my.cnf ##实例的配置文件
│??└── mysql ##实例的启动文件
└── test
[root@mysql /]# cat /data/3306/my.cnf
[client]
port =3306
socket =/data/3306/mysql.sock
[mysql]
no-auto-rehash
[mysqld]
user = mysql
port =3306
socket =/data/3306/mysql.sock
basedir =/application/mysql
datadir =/data/3306/data
open_files_limit =1024
back_log =600
max_connections =800
max_connect_errors =3000
table_cache =614
external-locking = FALSE
max_allowed_packet =8M
sort_buffer_size =1M
join_buffer_size =1M
thread_cache_size =100
thread_concurrency =2
query_cache_size =2M
query_cache_limit =1M
query_cache_min_res_unit =2k
#default_table_type = InnoDB
thread_stack =192K
#transaction_isolation = READ-COMMITTED
tmp_table_size =2M
max_heap_table_size =2M
long_query_time =1
#log_long_format
#log-error = /data/3306/error.log
#log-slow-queries = /data/3306/slow.log
pid-file =/data/3306/mysql.pid
log-bin =/data/3306/mysql-bin
relay-log =/data/3306/relay-bin
relay-log-info-file =/data/3306/relay-log.info
binlog_cache_size =1M
max_binlog_cache_size =1M
max_binlog_size =2M
expire_logs_days =7
key_buffer_size =16M
read_buffer_size =1M
read_rnd_buffer_size =1M
bulk_insert_buffer_size =1M
#myisam_sort_buffer_size = 1M
#myisam_max_sort_file_size = 10G
#myisam_max_extra_sort_file_size = 10G
#myisam_repair_threads = 1
#myisam_recover
lower_case_table_names =1
skip-name-resolve
slave-skip-errors =1032,1062
replicate-ignore-db=mysql
server-id =1
innodb_additional_mem_pool_size =4M
innodb_buffer_pool_size =32M
innodb_data_file_path = ibdata1:128M:autoextend
innodb_file_io_threads =4
innodb_thread_concurrency =8
innodb_flush_log_at_trx_commit =2
innodb_log_buffer_size =2M
innodb_log_file_size =4M
innodb_log_files_in_group =3
innodb_max_dirty_pages_pct =90
innodb_lock_wait_timeout =120
innodb_file_per_table =0
[mysqldump]
quick
max_allowed_packet =2M
[mysqld_safe]
log-error=/data/3306/mysql_oldboy3306.err
pid-file=/data/3306/mysqld.pid
[root@mysql /]# cat /data/3307/my.cnf
[client]
port =3307
socket =/data/3307/mysql.sock
[mysql]
no-auto-rehash
[mysqld]
user = mysql
port =3307
socket =/data/3307/mysql.sock
basedir =/application/mysql
datadir =/data/3307/data
open_files_limit =1024
back_log =600
max_connections =800
max_connect_errors =3000
table_cache =614
external-locking = FALSE
max_allowed_packet =8M
sort_buffer_size =1M
join_buffer_size =1M
thread_cache_size =100
thread_concurrency =2
query_cache_size =2M
query_cache_limit =1M
query_cache_min_res_unit =2k
#default_table_type = InnoDB
thread_stack =192K
#transaction_isolation = READ-COMMITTED
tmp_table_size =2M
max_heap_table_size =2M
#long_query_time = 1
#log_long_format
#log-error = /data/3307/error.log
#log-slow-queries = /data/3307/slow.log
pid-file =/data/3307/mysql.pid
#log-bin = /data/3307/mysql-bin
relay-log =/data/3307/relay-bin
relay-log-info-file =/data/3307/relay-log.info
binlog_cache_size =1M
max_binlog_cache_size =1M
max_binlog_size =2M
expire_logs_days =7
key_buffer_size =16M
read_buffer_size =1M
read_rnd_buffer_size =1M
bulk_insert_buffer_size =1M
#myisam_sort_buffer_size = 1M
#myisam_max_sort_file_size = 10G
#myisam_max_extra_sort_file_size = 10G
#myisam_repair_threads = 1
#myisam_recover
lower_case_table_names =1
skip-name-resolve
slave-skip-errors =1032,1062
replicate-ignore-db=mysql
server-id =3
innodb_additional_mem_pool_size =4M
innodb_buffer_pool_size =32M
innodb_data_file_path = ibdata1:128M:autoextend
innodb_file_io_threads =4
innodb_thread_concurrency =8
innodb_flush_log_at_trx_commit =2
innodb_log_buffer_size =2M
innodb_log_file_size =4M
innodb_log_files_in_group =3
innodb_max_dirty_pages_pct =90
innodb_lock_wait_timeout =120
innodb_file_per_table =0
[mysqldump]
quick
max_allowed_packet =2M
[mysqld_safe]
log-error=/data/3307/mysql_oldboy3307.err
pid-file=/data/3307/mysqld.pid
[root@mysql /]# chown -R mysql.mysql /data
[root@mysql /]# find /data -type f -name "my.cnf"|xargs ls -l ##将my.cnf文件权限设置成644
-rw-r--r--.1 mysql mysql 189910月292013/data/3306/my.cnf
-rw-r--r--.1 mysql mysql 190110月292013/data/3307/my.cnf
[root@mysql /]# find /data -type f -name "mysql"|xargs ls -l ##由于mysql脚本中保存了登录数据库的密码,需要将文件权限设置成700,只允许root,mysql访问
-rw-r--r--.1 mysql mysql 13077月152013/data/3306/mysql
-rw-r--r--.1 mysql mysql 13077月212013/data/3307/mysql
[root@mysql /]# find /data -type f -name "mysql"|xargs chmod 700
[root@mysql /]# find /data -type f -name "mysql"|xargs ls -l
-rwx------.1 mysql mysql 13077月152013/data/3306/mysql
-rwx------.1 mysql mysql 13077月212013/data/3307/mysql
[root@mysql /]# ll /application/mysql/bin/mysql
-rwxr-xr-x.1 root root 53453564月816:05/application/mysql/bin/mysql
[root@mysql /]# tail -1/etc/profile
export PATH=/application/mysql/bin:$PATH ##添加如下行
[root@mysql /]# source /etc/profile ##让其生效
[root@mysql /]# echo $PATH
/application/mysql/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
cd /application/mysql/scripts/##注意和MySQL 5.1的路径不同,MySQL 5.1 不在mysql/bin下
./mysql_install_db --basedir=/application/mysql --datadir=/data/3306/data/--user=mysql
./mysql_install_db --basedir=/application/mysql --datadir=/data/3307/data/--user=mysql
[root@mysql scripts]#/data/3306/mysql start
StartingMySQL...
[root@mysql scripts]#/data/3307/mysql start
StartingMySQL...
查看是否启动成功
[root@mysql scripts]# netstat -lntup|grep mysql
tcp 000.0.0.0:33060.0.0.0:* LISTEN 4614/mysqld
tcp 000.0.0.0:33070.0.0.0:* LISTEN 5412/mysqld
[root@mysql scripts]# mysqladmin -uroot password 123456 -S /data/3306/mysql.sock
[root@mysql scripts]# mysqladmin -uroot password 123456 -S /data/3307/mysql.sock
[root@mysql scripts]# sed -i '13 s#oldboy#123456#g'/data/3306/mysql
[root@mysql scripts]# sed -n '13p'/data/3306/mysql
mysql_pwd="123456"
[root@mysql scripts]# sed -i '13 s#oldboy#123456#g' /data/3307/mysql
[root@mysql scripts]# sed -n '13p' /data/3307/mysql
mysql_pwd="123456"
[root@mysql scripts]#
[root@mysql scripts]#/data/3306/mysql stop
StopingMySQL...
[root@mysql scripts]#/data/3307/mysql stop
StopingMySQL...
[root@mysql scripts]#