【转】centos 6.2 安装mysql-5.5.17

转自:http://icooke.blog.51cto.com/4123148/764796

1.安装相关库文件(没有的话就安装,有就不用安装了)  

# yum install bison gcc gcc-c++ autoconf automake zlib* libxml* ncurses-devel libtool-ltdl-devel*
 
2.安装cmake包
# wget http://www.cmake.org/files/v2.8/cmake-2.8.6.tar.gz
 
# tar zxvf cmake-2.8.6.tar.gz
# cd cmake-2.8.6/
# ./configure
# gmake
# gmake install  
 
3.添加用户和创建数据库目录和权限设置
# useradd mysql
# mkdir -p /data/mysql
# chown -R root:mysql /data/mysql
 
4.MYSQL 5.5.17
# wget http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.17.tar.gz/from/http://mysql.ntu.edu.tw/
 在http://www.mysql.com/downloads/中下载  Community Server sourcecode最后一个
用户名:名.姓名@qq.com 密码:大写小写数字
# tar zxvf mysql-5.5.17.tar.gz
# cd mysql-5.5.17
# cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/mysql -DSYSCONFDIR=/etc/
# gmake
# gmake install
 
5.设置mysql配置文件
 
# cd /usr/local/mysql
# cp ./support-files/my-huge.cnf /etc/my.cnf
[red part may be different]红色部分可能不一样。。tab一下看看my-XXX
 
5.1编辑/etc/my.cnf
# vi /etc/my.cnf
在 [mysqld] 段增加
datadir = /data/mysql
wait-timeout = 30
max_connections = 512
max_connect_errors = 10000000
default-storage-engine = MyISAM
 
在 [mysqld] 段修改
max_allowed_packet = 16M 
 
6.初始化数据库
 
# ./scripts/mysql_install_db --datadir=/data/mysql --basedir=/usr/local/mysql  --defaults-file=/etc/my.cnf --user=mysql
# cp ./support-files/mysql.server /etc/rc.d/init.d/mysqld
# chmod 755 /etc/rc.d/init.d/mysqld
# chkconfig --add mysqld
 
7.设置启动脚本变量 
  编辑 /etc/rc.d/init.d/mysqld
# vi /etc/rc.d/init.d/mysqld
basedir=/usr/local/mysql
datadir=/data/mysql 
 
8.设置变量环境
# echo "PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile (永久生效)
source /etc/profile
# export PATH=$PATH:/usr/local/mysql/bin (当前生效)
 
9.启动服务
# service mysqld start
 
10.设置数据库管理员root密码
# mysqladmin -u root password '123456'
# service mysqld restart
 
11.进入Mysql 
# mysql -u root -p
posted @ 2013-03-15 19:37  dorothychai  阅读(175)  评论(0编辑  收藏  举报