1、创建mysql用户
/usr/sbin/groupadd mysql -g 500
/usr/sbin/useradd -g mysql -u 500 mysql
2、创建目录
mkdir -p /home/tbt/mysqldata
mkdir -p /home/tbt/mysql
chown mysql.mysql -R /home/tbt/mysqldata
chown mysql.mysql -R /home/tbt/mysql
3、安装依赖包
apt-get install libncurses5-dev cmake make gcc g++ -y
4、解压编译
tar zxvf /home/tbt/src/mysql-5.5.38.tar.gz -C /home/tbt/src/
cd /home/tbt/src/mysql-5.5.38
cmake -DCMAKE_INSTALL_PREFIX=/home/tbt/mysql \
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_EXTRA_CHARSETS:STRING=utf8,gbk \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DMYSQL_DATADIR=/home/tbt/mysqldata \
-DMYSQL_TCP_PORT=3306 \
make && make install
5、初始化
/home/tbt/mysql/scripts/mysql_install_db --user=mysql --datadir=/home/tbt/mysqldata --basedir=/home/tbt/mysql
6、配置文件及启动脚本
cp /home/tbt/mysql/support-files/my-medium.cnf /home/tbt/mysql/my.cnf
cp /home/tbt/mysql/support-files/mysql.server /etc/init.d/mysqld
sed -i ‘s/conf=\/etc\/my.cnf/conf=\/home\/tbt\/mysql\/my.cnf/‘ /etc/init.d/mysqld
sed -i ‘s/^basedir=/&\/home\/tbt\/mysql/‘ /etc/init.d/mysqld
sed -i ‘s/^datadir=/&\/home\/tbt\/mysqldata/‘ /etc/init.d/mysqld
echo "/etc/init.d/mysqld start" >> /etc/rc.local
/etc/init.d/mysqld start
7、设置root用户密码
/home/tbt/mysql/bin/mysqladmin -uroot password "zhyzhy"
8、修改环境变量
echo "export PATH=$PATH:/home/tbt/mysql/bin" >> /etc/profile.d/mysql.sh
source /etc/profile.d/mysql.sh
本文出自 “星之殇洋” 博客,请务必保留此出处http://5430078.blog.51cto.com/5420078/1559383
原文地址:http://5430078.blog.51cto.com/5420078/1559383