一. Centos 用 wget 下載須要的軟件,保存到目錄/home/zwl/MySql/下mysql
wget http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.17.tar.gz/from/http://mysql.ntu.edu.tw/sql
wget www.cmake.org/files/v2.8/cmake-2.8.6.tar.gz數據庫
wget http://ftp.gnu.org/gnu/bison/bison-2.5.tar.gzbootstrap
二. 安裝 cmakesocket
cd /usr/local/srcui
tar zxvf cmake-2.8.4.tar.gz
cd cmake-2.8.4
./bootstrap
make
make install
cd ../
tar zxvf bison-2.5.tar.gz
cd bison-2.5
./configure
make
make install日誌
cd ../server
三. 編譯安裝 MySQL 5.5.13ip
1.添加MySql用戶,和分組ci
/usr/sbin/groupadd mysql
/usr/sbin/useradd -g mysql mysql
//建立和受權MySql目錄
mkdir -p /home/mysql/mysql4309
cd mysql4309
//建立所需的目錄
mkdir log--日誌文件夾
mkdir src --源碼文件夾
mkdir data --數據文件夾
//受權目錄
chmod a+w mysql4309/
//修改mysql及所屬分組文件屬主
chown -R mysql:mysql /home/mysql/mysql4309
//將MySql源碼包移動到/home/mysql/mysql4309/的src目錄中
mv mysql-5.5.17.tar.gz /home/mysql/mysql4309/src
//移動以後,執行解壓命令
tar -xzvf mysql-5.5.17.tar.gz
cd mysql-5.5.17
//使用cmake命令編譯MySql
先輸入cmake(先不敲回車)
修改以下部分中的數據後粘貼過來:
-DCMAKE_INSTALL_PREFIX=/home/mysql/mysql4309
-DSYSCONFDIR=/home/mysql/mysql4309
-DMYSQL_UNIX_ADDR=/home/mysql/mysql4309/mysql.sock
-DMYSQL_DATADIR=/home/mysql/mysql4309/data
-DDEFAULT_COLLATION=utf8_general_ci
-DDEFAULT_CHARSET=utf8
-DEXTRA_CHARSETS=all
-DWITH_MYISAM_STORAGE_ENGINE=1
-DWITH_INNOBASE_STORAGE_ENGINE=1
-DWITH_READLINE=1 -DWITH_ZLIB=system
-DENABLED_LOCAL_INFILE=1
-DMYSQL_USER=mysql
-DWITH_DEBUG=0
-DMYSQL_TCP_PORT=4309
當出現以下信息時:
-- Configuring done
-- Generating done
-- Build files have been written to: /home/mysql/mysql4309/src/mysql-5.5.17
則說明已經編譯完成了。
四. 執行make命令(此處可能須要5-8分鐘左右)
當出現以下標示:
[100%] Built target my_safe_process
代表make完成了
而後安裝MySql,當在data中有mysql和test文件夾時,這證實安裝成功
ll ../../data
五.執行初始化
cd script
../script/mysql_install_db --defaults-file=/home/mysql/mysql4309/my.cnf --basedir=/home/mysql/mysql4309 --datadir=/home/mysql/mysql4309/data --user=mysql
六.啓動MySql
cd ../support-files/
./mysql.server start
當出現此標記時則,啓動成功
Starting MySQL.... [ OK ]
MySQL 配置文件
MySql配置文件my.cnf配置詳解
[mysqld]
port = 4309--指定端口
socket = /home/mysql/mysql4309/mysql.sock指定sock文件
basedir=/home/mysql/mysql4309--指定數據庫安裝目錄
datadir=/home/mysql/mysql4309/data--指定數據庫數據文件
# Disabling symbolic-links is recommended to prevent assorted security risks
server-id = 4309--標示
log-bin = mysql-bin--二進制日誌
log-bin-index = mysql-bin.index
relay-log = slave-relay-bin
relay-log-index = slave-relay-bin.index
sync_master_info = 1
sync_relay_log = 1
sync_relay_log_info = 1
-- 5.5之後的MySql下面4行已經無效
#master-host=101.201.140.214
#master-user=root
#master-password=root4308
#master-port=4308
#replicate-do-db=ng_base
#replicate-do-db=ng_push
symbolic-links=0
max_connections=2048
#skip-grant-tables
#skip-locking
back_log = 500
key_buffer_size = 512M
max_allowed_packet = 4M
thread_stack = 256K
table_cache = 128K
sort_buffer_size = 6M
read_buffer_size = 4M
join_buffer_size = 8M
myisam_sort_buffer_size = 64M
table_cache = 512
thread_cache_size = 256
query_cache_size = 64M
tmp_table_size = 256M
max_connect_errors = 72000
wait_timeout = 28800
interactive_timeout=28800
innodb_buffer_pool_size=768M
innodb_log_file_size=256M
innodb_log_buffer_size=8M
innodb_additional_mem_pool_size=4M
innodb_flush_log_at_trx_commit=0
innodb_thread_concurrency=20
character-set-server=utf8
default-storage-engine=InnoDB--指定存儲引擎
[mysqld_safe]log-error=/home/mysql/mysql4309/log/mysqld4309.log--指定日誌文件pid-file=/home/mysql/mysql4309/data/mysqld.pid--指定pid文件