1.安装相关库文件(没有的话就安装,有就不用安装了)
1 | # yum install bison gcc gcc-c++ autoconf automake zlib* libxml* ncurses-devel libtool-ltdl-devel* |
2.安装cmake包
1 2 3 4 5 6 7 | # 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.添加用户和创建数据库目录和权限设置
1 2 3 | # useradd mysql # mkdir -p /data/mysql # chown -R root:mysql /data/mysql |
4.MYSQL 5.5.27
1 2 3 4 5 6 7 | # wget http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.27.tar.gz/from/http://mysql.ntu.edu.tw/ # tar zxvf mysql-5.5.27.tar.gz # cd mysql-5.5.27 # cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/mysql -DSYSCONFDIR=/etc/ # gmake # gmake install |
5.设置mysql配置文件
1 2 | # cd /usr/local/mysql # cp ./support-files/my-huge.cnf /etc/my.cnf |
5.1编辑/etc/my.cnf
1 | # vi /etc/my.cnf |
在 [mysqld] 段增加
1 2 3 4 5 | datadir = /data/mysql wait-timeout = 30 max_connections = 512 max_connect_errors = 10000000 default-storage-engine = MyISAM |
在 [mysqld] 段修改
1 | max_allowed_packet = 16M |
6.初始化数据库
1 2 3 4 | # ./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
1 2 3 | # vi /etc/rc.d/init.d/mysqld basedir=/usr/local/mysql datadir=/data/mysql |
8.设置变量环境
1 2 | # echo "PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile (永久生效) # export PATH=$PATH:/usr/local/mysql/bin (当前生效) |
9.启动服务
1 | # service mysqld start |
10.设置数据库管理员root密码
1 2 | # mysqladmin -u root password '123456' # service mysqld restart |
11.进入Mysql
1 | # mysql -u root -p |