1、安装mysql5.5及5.5以上版本需要安装cmake
1)下载cmake
wget --no-check-certificate http://www.cmake.org/files/v2.8/cmake-2.8.7.tar.gz
2)解压编译安装
先安装所依赖的包:
yum -y install gcc*
tar zvxf cmake-2.8.7.tar.gz
cd cmake-2.8.7
./configure
make && make install
2、安装mysql
1)下载mysql
wget http://mirrors.sohu.com/mysql/MySQL-5.5/mysql-5.5.47.tar.gz
2)创建mysql用户与用户组
groupadd mysql
useradd -g mysql mysql
3)解压安装
tar zvxf mysql-5.5.47.tar.gz
cd mysql-5.5.47
使用cmake编译:
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/mysql/data \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_EXTRA_CHARSETS:STRING=all \
-DWITH_DEBUG=0 \
-DWITH_SSL=yes \
-DWITH_READLINE=1 \
-DENABLED_LOCAL_INFILE=1
make && make install
4)生成新的mysql权限表
mkdir -p /mysql/data
./scripts/mysql_install_db --user=mysql -datadir=/mysql/data
#此处如不指定datadir,到启动时会报错
5)权限设置
cd /usr/local/mysql
chown -R mysql:mysql /usr/local/mysql
chown -R root .
chown -R mysql data
cp support-files/my-medium.cnf /etc/my.cnf
/usr/local/mysql/bin/mysqld_safe --user=mysql &
cp support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
/etc/init.d/mysqld start
6)验证
/usr/local/mysql/bin/mysql
Select @@version