CentOS下安装MySQL
1. 软件获得
可以从官方网站获得稳定版本mysql5.1.58。选择souce code,下载压缩包安装文件。
若主机直接连接公网,可在主机上直接使用如下方式获得软件包:
wget http://dev.mysql.com/get/Downloads/MySQL-5.1/mysql-5.1.58.tar.gz/from/http://ftp.jaist.ac.jp/pub/mysql/
2. 安装方法
1) 解压软件包
tar xvf mysql-5.1.58.tar.gz
2) 配置mysql用户
useradd –d /home/mysql mysql
编辑mysql用户的.bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin:/sbin
export PATH
export PS1="[\u@\h \w ]\$"
3) 配置,编译,编译安装
./configure --prefix=/home/mysql/ \
--with-unix-socket-path=/home/mysql/mysql.sock \
--with-big-tables \
--with-charset=utf8 \
--with-collation=utf8_general_ci \
--with-extra-charsets=gbk,gb2312,utf8 \
--with-client-ldflags=-all-static \
--with-mysqld-ldflags=-all-static \
--with-plugins=partition,innobase,myisammrg \
--with-pthread \
--with-readline \
--without-debug \
--without-isam \
--enable-assembler \
--enable-local-infile \
--enable-thread-safe-client
make
make install
4) 创建MySQL数据库
创建数据库之前,先编辑my.cnf文件。my.cnf文件放在MySQL的安装目录下面(/home/mysql)。my.cnf 文件内容如下:
[client]
#character-set-server = utf8
port = 3306
socket = /tmp/mysql.sock
[mysqld]
character-set-server = utf8
replicate-ignore-db = mysql
replicate-ignore-db = test
replicate-ignore-db = information_schema
user = mysql
port = 3306
socket = /tmp/mysql.sock
basedir = /home/mysql
datadir = /home/mysql/data
log-error = /home/mysql/log/error.log
pid-file = /home/mysql/mysql.pid
open_files_limit = 10240
back_log = 600
max_connections = 5000
max_connect_errors = 6000
table_cache = 614
external-locking = FALSE
max_allowed_packet = 32M
sort_buffer_size = 1M
join_buffer_size = 1M
thread_cache_size = 300
#thread_concurrency = 8
query_cache_size = 512M
query_cache_limit = 2M
query_cache_min_res_unit = 2k
default-storage-engine = MyISAM
thread_stack = 192K
transaction_isolation = READ-COMMITTED
tmp_table_size = 246M
max_heap_table_size = 246M
long_query_time = 3
log-slave-updates
log-bin = /home/mysql/log/binlog
binlog_cache_size = 4M
binlog_format = MIXED
max_binlog_cache_size = 8M
max_binlog_size = 1G
relay-log-index = /home/mysql/log/relaylog
relay-log-info-file = /home/mysql/log/relaylog
relay-log = /home/mysql/log/relaylog
expire_logs_days = 30
key_buffer_size = 256M
read_buffer_size = 1M
read_rnd_buffer_size = 16M
bulk_insert_buffer_size = 64M
myisam_sort_buffer_size = 128M
myisam_max_sort_file_size = 10G
myisam_repair_threads = 1
myisam_recover
interactive_timeout = 120
wait_timeout = 120
相关新闻>>
- 发表评论
-
- 最新评论 更多>>