mysql源码安装(简化版)

1.添加组和用户

groupadd mysql

useradd -g mysql mysql -s /bin/false

mkdir /data/mysql -p

chown -R mysql:mysql /data/mysql

 

2.下载mysql

cd  /usr/local

wget http://cdn.mysql.com/archives/mysql-5.6/mysql-5.6.21.tar.gz

 

3.下载依赖包

yum install  -y bison cmake gcc gcc-c++ libaioncurses-devel

 

4.编译安装mysql

cd /usr/local

tar xf mysql-5.6.21.tar.gz

mv mysql-5.6.21 mysql

cd mysql

cmake .-DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/mysql-DSYSCONFDIR=/etc

make;make install

 

5.优化和初始化mysql

rm -rf /etc/my.cnf

cd /usr/local/mysql

./scripts/mysql_install_db --user=mysql--basedir=/usr/local/mysql --datadir=/data/mysql #初始化mysql

ln -s /usr/local/mysql/my.cnf  /etc/my.cnf

cp ./support-files/mysql.server/etc/rc.d/init.d/mysqld

chmod 755 /etc/init.d/mysqld

chkconfig mysqld on

 

 

6.启动mysql

vi /etc/rc.d/init.d/mysqld

basedir=/usr/local/mysql   #添加

datadir=/data/mysql       #添加

  

service mysqld restart

echo "PATH=$PATH:/usr/local/mysql/bin">>/etc/profile

source /etc/profile


你可能感兴趣的:(mysql)