一、实验环境
CentOS6.5  
mysql版本:mysql-5.1.72.tar.gz 
二、实验步骤  
1)创建mysql用户,并制定shell类型及不创建加目录。
useradd mysql -s /sbin/nologin -M 
2)解压mysql-5.1.72.tar.gz 
tar xf mysql-5.1.72.tar.gz   
3)编译安装mysql    
yum  -y install ncurses  
cd  mysql-5.1.72   
./configure \
--prefix=/application/mysql5.1.72 \
--with-unix-socket-path=/application/mysql5.1.72/tmp/mysql.sock \
--localstatedir=/application/mysql5.1.72/data \
--enable-assembler \
--enable-thread-safe-client \
--with-mysqld-user=mysql \
--with-big-tables \
--without-debug \
--with-pthread \
--enable-assembler \
--with-extra-charsets=complex \
--with-readline \
--with-ssl \
--with-embedded-server \
--enable-local-infile \
--with-plugins=partition,innobase \
--with-mysqld-ldflags=-all-static \
--with-client-ldflags=-all-static 
make && make install   
3)初始化数据库(把mysql-5.1.72/support-files/my-small.cnf拷贝到/etc/my.cnf)     
cp -r my-small.cnf /etc/my.cnf   
mkdir -p /application/mysql/data     
chown -R mysql.mysql  /application/mysql/  
/application/mysql/my_install_db --basedir=/application/mysql --datadir=/application/mysql/data/ --group=mysql --user=mysql 
4)配置启动mysql   
sed -i ‘s#/usr/local/mysql#/application/mysql#g‘ /application/mysql/bin/mysqld_safe  
/applicaiton/mysql/bin/mysqld_safe & (后台启动)
5)检查是否启动成功 
lsof -i :3306    
6)配置环境变量把如下加入到/etc/profile配置文件中或者把文件路径改正确  
PATH="/application/mysql/bin:$PATH"
source /etc/profile     
cp /application/mysql/bin/* /usr/local/sbin/
7)登录mysql   
~]#mysql  
Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.
mysql> 
8)设置密码、修改密码
mysqladmin -uroot password "xxx"
mysqladim -uroot -pxxx password "xxx123"
9)配置让mysql启动更简单  
cp mysql.server /etc/init.d/mysqld  
sed -i ‘s#/usr/local/mysql#/application/mysql#g‘ /etc/init.d/mysqld   
chmod +x /etc/init.d/mysqld   
chkconfig mysqld on   
chkconfig --list mysqld on  
10)安装mysql完成,下次启动使用如下命名即可 
/etc/init.d/mysqld  start     
如需详细步骤请参考:http://purify.blog.51cto.com/10572011/1771783
本文出自 “叫醒你的不是闹钟而是梦想” 博客,请务必保留此出处http://purify.blog.51cto.com/10572011/1789841
原文:http://purify.blog.51cto.com/10572011/1789841