[root@raid ~]# rpm -qa | grep mysql
[root@raid ~]# yum -y install gcc gcc-c++ ncurses-devel bison libaio-devel ncurses-devel cmake
3、创建进程用户mysql[root@raid ~]# useradd -s /sbin/nologin mysql
4、解压、配置安装mysql[root@raid ~]# tar xzvf mysql-5.5.24.tar.gz
[root@raid ~]# cd mysql-5.5.24
[root@raid mysql-5.5.24]# cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_EXTRA_CHARSETS=all \
-DSYSCONFDIR=/etc \
-DMYSQL_DATADIR=/home/mysql/ \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_SSL=system \
-DMYSQL_TCP_PORT=3306 \
-DENABLE_DOWNLOADS=1 \
-DWITH_SSL=bundled
DCMAKE_INSTALL_PREFIX:mysql软件安装位置
DDEFAULT_CHARSET:默认字符集
DDEFAULT_COLLATION:默认字符校验
DWITH_EXTRA_CHARSETS:额外的编码,请使用ALL来编译
DWITH_MYISAM_STORAGE_ENGINE:安装 myisam 存储引擎
DWITH_INNOBASE_STORAGE_ENGINE:安装 innodb 存储引擎
DWITH_MEMORY_STORAGE_ENGINE:安装 memory 存储引擎
DWITH_READLINE:支持readline库,支持一行行读取数据
DENABLED_LOCAL_INFILE:启用本地加载数据
DMYSQL_DATADIR:数据目录
DMYSQL_USER:指定mysql的运行用户
DMYSQL_TCP_PORT=3306:mysql的端口号默认是3306
[root@raid mysql-5.5.24]# make && make install
5、修改mysql安装目录的所有者,所属组[root@localhost mysql-5.5.24]# chown -R mysql:mysql /usr/local/mysql/
6、创建修改my.cnf配置文件[root@localhost mysql-5.5.24]# cp support-files/my-medium.cnf /etc/my.cnf
7、添加系统服务[root@localhost mysql-5.5.24]# vim /etc/profile #修改系统环境变量
最后一行添加:export PATH=$PATH:/usr/local/mysql/bin/
[root@localhost mysql-5.5.24]# source /etc/profile #重新读取系统环境变量
[root@localhost mysql-5.5.24]# cp support-files/mysql.server /etc/init.d/mysqld #添加系统服务
[root@localhost mysql-5.5.24]# chmod +x /etc/init.d/mysqld #添加执行权限
[root@localhost mysql-5.5.24]# chkconfig --add mysqld #将mysqld添加为系统服务
[root@localhost mysql-5.5.24]# /usr/local/mysql/scripts/mysql_install_db \
--user=mysql \
--ldata=/var/lib/mysql \
--basedir=/usr/local/mysql \
--datadir=/home/mysql
user:指定数据库管理员,也就是是谁管理数据库
basedir:指定mysql软件安装位置
datadir:指定mysql数据安装位置
[root@localhost mysql-5.5.24]# vim /etc/init.d/mysqld
找到basedir、datadir进行赋值basedir=/usr/local/mysql #约46行数据库安装目录
datadir=/home/mysql #约47行数据存放目录
[root@localhost mysql-5.5.24]# service mysqld start
[root@localhost mysql-5.5.24]# netstat -anpt | grep 3306 #查看端口
[root@localhost ~]# mysqladmin -u root password '123'#设置新密码
[root@localhost ~]# mysql -uroot -p123 #登录mysql
[root@localhost ~]# yum install \
libjpeg-devel \
libpng-devel \
freetype-devel \
zlib-devel \
gettext-devel \
libXpm-devel \
libxml2-devel \
fontconfig-devel \
openssl-devel \
openssl-devel \
bzip2-devel \
libxml2 \
libxml2-devel
[root@localhost ~]# tar xzvf gd-2.0.35.tar.gz -C /usr/src/
[root@localhost ~]# cd /usr/src/gd/2.0.35/
[root@localhost 2.0.35]# ./configure --prefix=/usr/local/gd
[root@localhost 2.0.35]# make && make install
[root@localhost ~]# tar xjvf php-5.4.5.tar.bz2 -C /usr/src
[root@localhost ~]# cd /usr/src/php-5.4.5/
[root@raid php-5.4.5]# ./configure \
--prefix=/usr/local/php5 \
--with-gd \
--with-zlib \
--with-mysql=/usr/local/mysql \
--with-config-file-path=/usr/local/php5 \
--enable-mbstring \
--with-jpeg-dir \
--with-openssl \
--disable-ipv6 \
--enable-fpm
[root@raid php-5.4.5]# make && make install
[root@raid php-5.4.5]# cp php.ini-development /usr/local/php5/php.ini
5、优化路径[root@raid php-5.4.5]# ln -s /usr/local/php5/bin/ /usr/local/bin/
[root@raid php-5.4.5]# ln -s /usr/local/php5/sbin/ /usr/local/sbin/