/ 中存储网

CentOS系统安装MySQL5.5数据库服务器

2014-12-30 00:12:59 来源:中存储网

最近在CentOS系统安装MySQL5.5数据库服务器,贡献安装步骤给大家:

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

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 (永久生效)
# 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