Linux编译安装Mysql步骤

一. Centos 用 wget 下载需要的软件,保存到目录/home/zwl/MySql/下

wget http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.17.tar.gz/from/http://mysql.ntu.edu.tw/

wget www.cmake.org/files/v2.8/cmake-2.8.6.tar.gz

wget http://ftp.gnu.org/gnu/bison/bison-2.5.tar.gz

二. 安装 cmake

cd /usr/local/src

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 ../

三. 编译安装 MySQL 5.5.13

1.添加MySql用户,和分组

/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文件

上一篇:微软Cloud+AI本地化社区贡献指南


下一篇:Crossing Rivers UVA - 12230 概率与期望