1、Centos6.2安装
选择minimal、自定义安装、base system[base,compatibility libraries,debugging tools]、development[development tools]
2、安装相关包
[root@Gavin software]# tar xf cmake-2.8.8.tar.gz [root@Gavin software]# cd cmake-2.8.8 [root@Gavin cmake-2.8.8]# ./configure [root@Gavin cmake-2.8.8]# gmake [root@Gavin cmake-2.8.8]# gmake install
3、安装依赖包
yum install ncurses-devel -y
yum地址:http://mirrors.aliyun.com/
4、开始安装mysql
1)创建用户和组
groupadd mysql useradd mysql -s /sbin/nologin -M -g mysql
2)解压编译MySQL
tar zxf mysql-5.5.32.tar.gz
cd mysql-5.5.32
cmake . -DCMAKE_INSTALL_PREFIX=/application/mysql-5.5.32 \ -DMYSQL_DATADIR=/application/mysql-5.5.32/data \ -DMYSQL_UNIX_ADDR=/application/mysql-5.5.32/tmp/mysql.sock \ -DDEFAULT_CHARSET=utf8 \ - -DDEFAULT_COLLATION=utf8_general_ci \ - -DEXTRA_CHARSETS=gbk,gb2312,utf8,ascii \ -DENABLED_LOCAL_INFILE=ON \ -DWITH_INNOBASE_STORAGE_ENGLINE=1 \ -DWITH_FEDERATED_STORAGE_ENGLINE=1 \ -DWITH-BLACKHOLE_STORAGE_ENGLINE=1 \ -DWITHOUT-EXAMPLE_STORAGE_ENGLINE=1 \ -DWITHOUT_PARTITION_STORAGE_ENGLINE=1 \ -DWITH_FAST_MUTEXES=1 \ -DWITH_ZLIB=bundled \ -DENABLED_LOCAL_INFILE=1 \ -DWITH_READLINE=1 \ -DWITH_EMBEDDED_SERVER=1 \ -DWITH_DEBUG=0
make
make install
ln -s /application/mysql-5.5.32/ /application/mysql
如未提示错误则安装成功!
3)初始化MySQL
a、查看默认模板配置文件
[root@Gavin mysql-5.5.32]# ll support-files/my*cnf -rw-r--r--. 1 root root 4759 Oct 18 03:48 support-files/my-huge.cnf -rw-r--r--. 1 root root 19809 Oct 18 03:48 support-files/my-innodb-heavy-4G.cnf -rw-r--r--. 1 root root 4733 Oct 18 03:48 support-files/my-large.cnf -rw-r--r--. 1 root root 4744 Oct 18 03:48 support-files/my-medium.cnf -rw-r--r--. 1 root root 2908 Oct 18 03:48 support-files/my-small.cnf
b、选择配置文件
[root@Gavin mysql-5.5.32]# /bin/cp support-files/my-small.cnf /etc/my.cnf
测试环境选小的,生产环境可以根据硬件选择,例如:my-innodb-heavy-4G.cnf
4)配置环境变量
[root@Gavin mysql-5.5.32]# echo 'export PATH=/application/mysql/bin:$PATH' >> /etc/profile [root@Gavin mysql-5.5.32]# tail -l /etc/profile [root@Gavin mysql-5.5.32]# source /etc/profile [root@Gavin mysql-5.5.32]# echo $PATH
5)初始化数据文件
a、建立mysql数据文件目录:
mkdir -p /application/mysql/data
b、授权mysql用户访问mysql安装目录
chown -R mysql.mysql /application/mysql
c、调整/tmp权限,否则初始化会出错误
chmod -R 1777 /tmp
d、安装mysql数据文件,请注意命令路径
[root@Gavin mysql-5.5.32]# cd /application/mysql/scripts/ [root@Gavin scripts]# ./mysql_install_db --basedir=/application/mysql/ --datadir=/application/mysql/data/ --user=mysql
5、设置常规方式启动关闭脚本
cd /software/mysql-5.5.32
拷贝mysql启动脚本到/etc/init.d/下
[root@Gavin mysql-5.5.32]# cp support-files/mysql.server /etc/init.d/mysqld
授权700权限,即脚本可执行
[root@Gavin mysql-5.5.32]# chmod 700 /etc/init.d/mysqld [root@Gavin mysql-5.5.32]# /etc/init.d/mysqld start Starting MySQL.. SUCCESS! [root@Gavin mysql-5.5.32]# netstat -lntup|grep mysql tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 31127/mysqld [root@Gavin mysql-5.5.32]# chkconfig mysqld on [root@Gavin mysql-5.5.32]# chkconfig --list mysqld [root@Gavin mysql-5.5.32]#mysqladmin -u root password 'gavinsw'