wget http://cdn.mysql.com/Downloads/MySQL-5.5/mysql-5.5.28.tar.gz
tar zxvf mysql-5.5.28.tar.gz -C /usr/local/src
cd /usr/local/src/mysql-5.5.28
yum -y install cmake
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS:STRING=utf8,gbk,gb2312 -DMYSQL_USER=mysql -DMYSQL_DATADIR=/data/mysql -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1
make install
useradd mysql -s /sbin/nologin
/usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/data/mysql --user=mysql
cp support-files/my-large.cnf /etc/my.cnf
vi /etc/my.cnf 在以下位置增加:datadir=/data/mysql
如下:
#########################################
# The MySQL server
[mysqld]
datadir = /data/mysql
port = 3306
socket = /tmp/mysql.sock
#########################################
install -m 755 support-files/mysql.server /etc/init.d/mysql
/usr/local/mysql/scripts/mysql_install_db
services mysql restart
chkconfig --add mysql
转载于:https://blog.51cto.com/jedy82/1059555