Linux源码安装mysql 5.5.13 (cmake编译)

来源:互联网 发布:js设置时间戳 编辑:程序博客网 时间:2024/06/05 04:36

1.安装make编译器

下载地址:http://www.gnu.org/software/make/

[c-sharp] view plain copy
  1. tar zxvf make-3.82.tar.gz  
  2. cd make-3.82  
  3. ./configure  
  4. make  
  5. make install  

2.安装bison

下载地址:http://www.gnu.org/software/bison/

[c-sharp] view plain copy
  1. tar zxvf bison-2.5.tar.gz  
  2. cd bison-2.5  
  3. ./configure  
  4. make  
  5. make install  

3.安装gcc-c++

下载地址:http://www.gnu.org/software/gcc/

[c-sharp] view plain copy
  1. tar zxvf gcc-c++-4.4.4.tar.gz  
  2. cd gcc-c++-4.4.4  
  3. ./configure  
  4. make  
  5. make install  

4.安装cmake

下载地址:http://www.cmake.org/

[c-sharp] view plain copy
  1. tar zxvf cmake-2.8.4.tar.gz  
  2. cd cmake-2.8.4  
  3. ./configure  
  4. make  
  5. make install  

5.安装ncurses

下载地址:http://www.gnu.org/software/ncurses/

[c-sharp] view plain copy
  1. tar zxvf ncurses-5.8.tar.gz  
  2. cd ncurses-5.8  
  3. ./configure  
  4. make  
  5. make install  

 

开始安装MySQL,下载地址:http://dev.mysql.com/

准备工作

[c-sharp] view plain copy
  1. groupadd mysql  
  2. useradd -r -g mysql mysql  

解压并安装MySQL

[c-sharp] view plain copy
  1. tar zxvf mysql-5.5.13.tar.gz  
  2. cd mysql-5.5.13  
  3. cmake . /  
  4. -DCMAKE_INSTALL_PREFIX=/usr/local/mysql /  
  5. -DINSTALL_DATADIR=/usr/local/mysql/data  
  6. make  
  7. make install  

完成后,继续下面的操作

[c-sharp] view plain copy
  1. cd /usr/local/mysql  
  2. chown -R mysql .  
  3. chgrp -R mysql .  
  4. scripts/mysql_install_db --user=mysql  
  5. chown -R root .  

下面的命令是可选的,将mysql的配置文件拷贝到/etc

[c-sharp] view plain copy
  1. cp support-files/my-medium.cnf /etc/my.cnf  

启动mysql:

[c-sharp] view plain copy
  1. bin/mysqld_safe --user=mysql &  
  2. #启动mysql,看是否成功  
  3. netstat -tnl|grep 3306  

上面是一种启动mysql的方法,还有一种简单的方便,如下:

[c-sharp] view plain copy
  1. #将mysql的启动服务添加到系统服务中  
  2. cp support-files/mysql.server /etc/init.d/mysql.server  
  3. #现在可以使用下面的命令启动mysql  
  4. service mysql.server start  
  5. #停止mysql服务  
  6. service mysql.server stop  
  7. #重启mysql服务  
  8. service mysql.server restart  

将mysql服务添加到开机启动项,让mysql服务开机启动

[c-sharp] view plain copy
  1. chkconfig --add mysql.server  
重启机器后,mysql服务就会自动启动了。

来源:http://blog.csdn.net/westmaniac/article/details/6535000

0 0
原创粉丝点击