编译安装mysql

从mysql 5.5版本开始,mysql源码安装开始使用cmake安装

一.软件包下载

1.MYSQL源码下载
到mysql官网选择Download→Community→Mysql Community Server→Source Code 版本
注:不要选择Linux-Generic版本,此版本为已经编译好的二进制版本

2.编译所需相关软件下载安装
yum install make bison cmake gcc-c++ ncurses ncurses-devel  -y(ncurses和ncurses-devel居然不依赖我很心痛)
注:一般系统都会默认安装有make,gcc-c++
我是最小化安装而且没有装任何包,所以只有make,其他都要自己装,喜欢编译的可以看帖子末尾


二.用户和目录
groupadd mysql
useradd -g mysql -s /sbin/nologin mysql
mkdir -p /data/mysql
chown -R mysql:mysql /data/mysql

三.MYSQL源码编译安装

1.编译安装
tar zxvf mysql-5.6.26.tar.gz
cd mysql-5.6.26
rm CMakeCache.txt(温馨提示,没有这个文件到不要tab手贱删错东西,没有这个文件tab默认会补全到CMakeLists.txt,这东西删了就没法编译啦)
cmake  -DCMAKE_INSTALL_PREFIX=/usr/local/mysql/  (其他编译参数请看文档末尾的链接)
make&&make install

2.启动准备
cd /usr/local/mysql  
rm /etc/my.cnf  在启动MySQL服务时,会按照一定次序搜索my.cnf,先在/etc目录下找,所以删一下防止意外,找不到则会搜索"$basedir/my.cnf,新版mysql的my.cnf初始化后在basedir下自动生成
./scripts/mysql_install_db  --user=mysql  --basedir=/usr/local/mysql --datadir=/data/mysql  初始化数据库(如有错误删除当前目录my.cnf  /etc/my.cnf  /etc/init.d/mysqld 三个文件) 
cp support-files/mysql.server /etc/init.d/mysqld 拷贝启动脚本
chmod 755 /etc/init.d/mysqld 

四.启动MYSQL

1.启动
/etc/init.d/mysqld start
看是否成功  
ps -aux|grep 'mysql'
netstat -lntp


2.设置root 密码:
/usr/local/mysql/bin/mysqladmin -u root password 'new-password'
/usr/local/mysql/bin/mysqladmin -u root -h localhost.localdomain password 'new-password'  
此步骤需要在数据库启动之后才能执行成功

3.开机启动
chkconfig �Cadd mysqld
chkconfig mysqld on

4.为了方便,将mysql 的bin目录加到PATH中export PATH=$PATH:/usr/local/mysql/bin    

注:本次安装没有添加别的参数,没有设置my.cnf,有问题不要骂我(端口我都没开,我只是安装了,2333),请参考下面附录链接,

附:
如果你编译过要重新编译,需要make clean → rm CMakeCache.txt
http://www.blogjava.net/kelly859/archive/2012/09/04/387005.htmlmysql编译参数
http://blog.chinaunix.net/uid-20639775-id-154429.html my.cnf配置文件详解
http://blog.csdn.net/naola2001/article/details/7740615 针对不同需求到my.cnf配置

下面是相关软件的编译安装
1)安装make编译器
下载地址:http://www.gnu.org/software/make/
tar zxvf make-3.82.tar.gz
cd make-3.82  
./configure  
make&&make install
2.安装bison
下载地址:http://www.gnu.org/software/bison/      
tar zxvf bison-2.5.tar.gz  
cd bison-2.5  
./configure  
make&&make install

3.安装gcc-c++
下载地址:http://www.gnu.org/software/gcc
tar zxvf gcc-c++-4.4.4.tar.gz  
cd gcc-c++-4.4.4  
./configure  
make&&make install

4.安装cmake
下载地址:http://www.cmake.org/
tar zxvf cmake-2.8.4.tar.gz  
cd cmake-2.8.4  
./configure  
make&&make install

5.安装ncurses
下载地址:http://www.gnu.org/software/ncurses/
tar zxvf ncurses-5.8.tar.gz  
cd ncurses-5.8  
./configure  
make&&make install

你可能感兴趣的:(源码下载,download,community,软件下载,百度妈妈)