Chinaunix首页 | 论坛 | 博客
  • 博客访问: 10454
  • 博文数量: 3
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 57
  • 用 户 组: 普通用户
  • 注册时间: 2013-10-24 19:36
文章分类
文章存档

2013年(3)

我的朋友

分类: LINUX

2013-10-30 00:40:12

创建用户:
groupadd -g 10001 mysql
/usr/sbin/useradd -g 10001 -u 10001 -s /sbin/nologin mysql

创建相关目录:
mkdir -p /usr/local/mysql/etc
mkdir -p /usr/lib/mysql
mkdir -p /data1/mysql/3306
mkdir -p /data0/log/mysql/3306/
mkdir -p /data1/tmp/3306
chown -R mysql:mysql /data1/mysql
chown -R mysql:mysql /data0/log/mysql
chmod 755 /data1/tmp
chown -R mysql:mysql  /data1/tmp



下载源码包
yum -y install ncurses-devel         

wget

wget

wget


安装mysql:
yum install gcc gcc-c++ make -y

tar zxvf cmake-2.8.6.tar.gz
cd cmake-2.8.6
./bootstrap                    #配置环境
make && make install      #编译 && 安装
cd ../

tar zxvf bison-2.5.tar.gz
cd bison-2.5
./configure                  #配置环境
make && make install    #编译 && 安装
cd ../

tar zxvf mysql-5.1.17.tar.gz
cd mysql-5.1.17/

cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/data1/tmp \
-DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS:STRING=all \
-DWITH-PLUGINS=ALL -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH-CLIENT-LDFLAGS=-ALL-STATIC \
-DWITH-MYSQLD-LDFLAGS=-ALL-STATIC -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 \
-DMYSQL_USER=mysql

#上面命令报错执行下面这条命令;
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/data1/tmp -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS:STRING=all -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1
#如果cmake报错,先删除 rm -rf  CMakeCache.txt
#然后运行  yum -y install ncurses-devel

make && make install
cd /usr/local/mysql/etc/
cp /usr/local/mysql/support-files/my-huge.cnf  my3306.cnf
vim /usr/local/mysql/etc/my3306.conf 
具体配置如下:
[mysqld]
server_id=1
default-storage-engine=myisam
datadir=/data1/mysql3306
port=3306
socket=/data1/tmp/mysql3306.sock
tmpdir=/tmp
log-bin=content3306
innodb_flush_log_at_trx_commit=1
sync_binlog=1
#binlog-do-db=bocc
log-slave-updates
skip-innodb
skip-slave-start
max_tmp_tables=128
tmp_table_size=256M
max_allowed_packet=4M
key_buffer=1024M
max_connections=1024
sort_buffer_size=16M
read_buffer_size=16M
join_buffer_size=16M
read_rnd_buffer_size=24M
myisam_sort_buffer_size=128M
max_heap_table_size=128M
query_cache_size=128M
query_cache_limit=2M
table_cache=2048
thread_cache=16
thread_concurrency=8
wait_timeout = 30
interactive_timeout = 30
long_query_time = 1
slow-query-log




#如果下面命令执行错误,使用kill杀死mysql进程,在重启mysql,再次执行;

初始化mysql:
/usr/local/mysql/scripts/mysql_install_db  --user=mysql --basedir=/usr/local/mysql/  --defaults-file=/usr/local/mysql/etc/my3306.cnf

开启mysql:
ulimit -HSn 65535 && /usr/local/mysql/bin/mysqld_safe --defaults-file=/usr/local/mysql/etc/my3306.cnf &

删除数据库 test:
 /usr/local/mysql/bin/mysqladmin -S /data1/tmp/mysql3306.sock -u root drop test

初始化数据库root密码:
/usr/local/mysql/bin/mysqladmin -S /data1/tmp/mysql3306.sock -uroot password 'xxx'

设置开机启动mysql:
vim /etc/rc.local
增加如下行:
ulimit -HSn 65535 && /usr/local/mysql/bin/mysqld_safe --defaults-file=/usr/local/mysql/etc/my3306.cnf &





















阅读(1316) | 评论(0) | 转发(1) |
0

上一篇:没有了

下一篇:VMware虚拟机增加硬盘

给主人留下些什么吧!~~