zoukankan      html  css  js  c++  java
  • linux下安装mysql

    一、编译安装cmake  

    2013-02-17 15:44:52|  分类: linux应用 |  标签:编译安装cmake   |举报 |字号 订阅

     
    编译安装cmake
    下载cmake源码包cmake-2.8.4.tar.gz,mv到/usr/local/src目录下
    [root@localhost ~]# cd /usr/local/src/  
    [root@localhost src]# tar xzvf cmake-2.8.7.tar.gz   
    [root@localhost src]# cd cmake-2.8.7 
    [root@localhost cmake-2.8.4]# ./bootstrap   
    ---------------------------------------------  
    CMake 2.8.4, Copyright 2000-2009 Kitware, Inc.  
    ---------------------------------------------  
    Error when bootstrapping CMake:  
    Cannot find appropriate C compiler on this system.  
    Please specify one using environment variable CC.  
    See cmake_bootstrap.log for compilers attempted.  
      
    ---------------------------------------------  
    Log of errors: /usr/local/src/cmake-2.8.4/Bootstrap.cmk/cmake_bootstrap.log  
    ---------------------------------------------  
    报错:缺少C的编译器。
     
    安装gcc编译器
    可以从Linux系统的安装盘中安装,也可以简单地用yum安装

    [root@localhost ~]# yum install gcc  
     
    继续cmake的安装

    [root@localhost cmake-2.8.4]# ./bootstrap   
    ---------------------------------------------  
    CMake 2.8.4, Copyright 2000-2009 Kitware, Inc.  
    C compiler on this system is: cc   
    ---------------------------------------------  
    Error when bootstrapping CMake:  
    Cannot find appropriate C++ compiler on this system.  
    Please specify one using environment variable CXX.  
    See cmake_bootstrap.log for compilers attempted.  
    ---------------------------------------------  
    Log of errors: /usr/local/src/cmake-2.8.4/Bootstrap.cmk/cmake_bootstrap.log  
    ---------------------------------------------  
    再次报错:缺少C++编译器。
     
    安装gcc-c++编译器
    同样可以从Linux系统的安装盘中安装,或者简单地用yum安装

    [root@localhost ~]# yum install gcc-c++  
     
    重复上面的操作

    [root@localhost cmake-2.8.4]# ./bootstrap   
     
    没有报错后,编译安装

    [root@localhost cmake-2.8.4]# gmake  
    [root@localhost cmake-2.8.4]# gmake install  
     
    开始正式安装Mysql
    ====================================================================

    二. 安装 cmake
    cd /usr/local/src
    tar zxvf cmake-2.8.7.tar.gz
    cd cmake-2.8.7
    ./bootstrap
    gmake
    gmake install
    检查安装 which cmake看结果可知安装是否正确
     
    二、

    在开始安装前,先说明一下mysql-5.6.4与较低的版本在安装上的区别,从mysql-5.5起,mysql源码安装开始使用cmake了, 因此当我们配置安装目录./configure --perfix=/.....的时候和以前的会有些区别,这点我们稍后会提到。

    一:解压缩mysql-5.6.4-m7-tar.zip

            1>  unzip mysql-5.6.4-m7-tar.zip   会生成mysql-5.6.4-m7-tar.gz的压缩文件

             2> tar -zxvf mysql-5.6.4-m7-tar.gz  会生成mysql-5.6.4-m7的文件夹

             接下来我们就要配置安装目录进行具体的安装了,这里需要注意的是利用cmake时需要安装cmake的应用程序。 

             下载压缩包cmake-2.8.10.1.tar.gz   解压缩  tar -zxvf cmake-2.8.10.1.tar.gz   得到文件 cmake-2.8.10.1    进入  cd cmake-2.8.10.1  <我们现在外层建立目录  mkdir cmake_exe>

                      (1)  配置安装目录  ./configure --prefix=/home/houqingdong/cmake_exe        (2)    make          (3)  make  install

             3>好了到这里我们的cmake已经安装成功了,进入mysql-5.6.4-m7           cd   /usr/ local/mysql-5.6.4-m7   <假设在外层已经建立mysql>

             4>根据转换关系执行:

                    cmake  -DCMAKE_INSTALL_PREFIX=/usr/local/mysql     回车       注意有的时候会出现提示:说没有这个cmake这个命令,但是cmake刚刚我们的确安装了,没关系,给它填上路径就行了:  export PATH=/home/houqingdong/cmake_exe/bin:$PATH    然后再运行就好了

             5>make                        make    install                执行完后会看到安装成功的提示

             6> useradd mysql 创建一个用户名为mysql的用户

             7> 安装默认的数据库:以mysql的身份执行(su - mysql)  cd   /usr/local/mysql/scripts/

                                                                              sudo ./mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data/ --user=mysql

              这里我执行的时候出现错误,因为执行sudo需要密码,但是我输入之后它提示我说mysql用户不在sudoers文件夹中:

             

              于是又回到root用户,执行: visudo      在 root    ALL=(ALL)              ALL   这一行下面加上:    mysql     ALL=(ALL)       ALL            赋予它root用户所有的权限

             

             执行完之后再去执行上面的就可以了:sudo ./mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data/ --user=mysql

            

             8>将mysql的配置文件和服务文件复制到系统配置路径下面

                 cp my-medium.config   /etc/my.conf                                  cp  mysql.server       /etc/init.d/mysqld

              

             9>启动服务

                  service  mysqld  start  || /etc/init.d/mysql start                    添加到开机自启动( chkconfig --add mysqld)

             

             10> 增加mysql的root用户的密码:  mysql -u root password  'your_password

              11>在进程中查看启动的情况    ps -ef | grep mysqld

              

              从里面可以看出mysql为root用户启动,还可以看到安装目录以及端口号等。

               12>链接到数据库:

                

    好了,今天磕磕碰碰的总算是安上了,不过还有部分流程没有弄懂,比如权限问题、授权问题等,明天卸载再重装一下,如果有改动或者添加的地方再补充。'

    还有可能在cmake . -DCMAKE_INSTALL_PREFIX=... 的时候出现这样的问题:

     Could NOT find Curses (missing  CURSES_LIBRARY CURSES_INCLUDE_PATH

    解决方法:

    [root@localhost software]# cd mysql-5.5.11
    [root@localhost mysql-5.5.11]# cmake .
    -- Could NOT find Curses (missing: CURSES_LIBRARY CURSES_INCLUDE_PATH)
    CMake Error at cmake/readline.cmake:82 (MESSAGE):
    Curses library not found. Please install appropriate package,

    remove CMakeCache.txt and rerun cmake.On Debian/Ubuntu, package name is libncurses5-dev, on Redhat and derivates it is ncurses-devel.
    Call Stack (most recent call first):
    cmake/readline.cmake:126 (FIND_CURSES)
    cmake/readline.cmake:216 (MYSQL_USE_BUNDLED_LIBEDIT)
    CMakeLists.txt:250 (MYSQL_CHECK_READLINE)


    -- Configuring incomplete, errors occurred!
    [root@localhost mysql-5.5.11]# rm CMakeCache.txt
    [root@localhost mysql-5.5.11]# yum install ncurses-devel
    Warning: Bison executable not found in PATH
    -- Configuring done
    -- Generating done
    -- Build files have been written to: /software/mysql-5.5.11
    [root@localhost mysql-5.5.11]# yum install bison

    按照提示来进行就可以了!!

    照着做能成功,有几处有点问题:
    1.第四步的cmake后面没有点,直接是空格
    2.第七步在root下执行的命令是visudo
    3.我觉得第七步应该在root用户下执行,否则找不到 mysql.plugin文件
    总之,真的很感谢!

  • 相关阅读:
    平衡树(Splay):Splaytree POJ 3580 SuperMemo
    数据结构:(平衡树,链表)BZOJ 1588[HNOI2002]营业额统计
    主席树:HDU 4417 Super Mario
    主席树:POJ2104 K-th Number (主席树模板题)
    后缀数组模板
    后缀数组:HDU1043 Longest Common Substring
    后缀数组:SPOJ SUBST1
    关于PHP程序员解决问题的能力
    现在写 PHP,你应该知道这些
    PHP 7 的几个新特性
  • 原文地址:https://www.cnblogs.com/bluewelkin/p/3775455.html
Copyright © 2011-2022 走看看