centos6.5 x86_64下编译安装MySQL-5.6.26

平台:centos6.5 64位系统最小化安装

先安装基本库

yum -y install gcc  gcc-c++ autoconf  automake  zlib  libxml* ncurses-devel  bison-devel libtool

一,安装Cmake

cd /usr/local/src/

wget http://www.cmake.org/files/v3.3/cmake-3.3.1.tar.gz

tar zxvf cmake-3.3.1.tar.gz 

cd cmake-3.3.1

 ./bootstrap 

gmake

gmake install


二,开始编译安装mysql

groupadd mysql

useradd -g mysql mysql

mkdir -p /usr/local/mysql

mkdir -p /usr/local/mysql/data

chown mysql:mysql -R /usr/local/mysql

chown mysql:mysql -R /usr/local/mysql/data


mv /etc/my.cnf /etc/my.cnf.bk(在启动MySQL服务时,会按照一定次序搜索my.cnf,先在/etc目录下找,找不到则会搜索"$basedir/my.cnf",MySQL编译安装后若使用这个配置文件启动,可能造成无法正常启动等问题。)


wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.26.tar.gz

tar zxvf mysql-5.6.26.tar.gz

cd mysql-5.6.26

cmake -L

cmake -LH    查看参数


cmake \

-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \

-DMYSQL_DATADIR=/usr/local/mysql/data \

-DSYSCONFDIR=/etc \

-DWITH_MYISAM_STORAGE_ENGINE=1 \

-DWITH_INNOBASE_STORAGE_ENGINE=1 \

-DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock \

-DMYSQL_TCP_PORT=3306 \

-DENABLED_LOCAL_INFILE=1 \

-DWITH_PARTITION_STORAGE_ENGINE=1 \

-DEXTRA_CHARSETS=all \

-DDEFAULT_CHARSET=utf8 \

-DDEFAULT_COLLATION=utf8_general_ci


make && make install


初始化数据库

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

chmod 775 /etc/init.d/mysql

chkconfig mysql on

export PATH=/usr/local/mysql/bin:$PATH

/usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql

service mysql start                      或者/usr/local/mysql/bin/mysql start


开机启动

 #echo 'export PATH=/usr/local/mysql/bin:$PATH' >> /etc/profile 

设置密码

#/usr/local/mysql/bin/mysqladmin -u root password "hello"


iptables -I INPUT -p tcp --dport 3306 -j ACCEPT


你可能感兴趣的:(mysql,5.6.25)