zoukankan      html  css  js  c++  java
  • MySQL源码安装小记【CentOS篇

    一、环境:

    系统版本:CentOS5.5

    MySQL版本:mysql-5.5.22

    二、步骤:

    1. 安装需要系统库相关库文件:

    [root@localhost ~]# yum install -y gcc gcc-c++ gcc-g77 autoconf automake zlib* fiex* libxml* ncurses-devel libmcrypt* libtool-ltdl-devel*

    2.需要的两个包

    [root@localhost /]# cd /usr/local/src/

    [root@localhost src]# ll

    total 29332

    -rw-r--r-- 1 root root  5517977 Jul 11 19:17 cmake-2.8.5.tar.gz

    -rw-r--r-- 1 root root 24464834 Jul 11 19:17 mysql-5.5.22.tar.gz

    1) 安装cmake

    [root@localhost src]# tar zxvf cmake-2.8.5.tar.gz

    [root@localhost src]# cd cmake-2.8.5

    [root@localhost cmake-2.8.5]# ./bootstrap

    …… ……

    -- Build files have been written to: /usr/local/src/cmake-2.8.5

    ---------------------------------------------

    CMake has bootstrapped.  Now run gmake.

    [root@localhost cmake-2.8.5]# gmake
    …… ……

    [100%] Building CXX object Tests/CMakeLib/CMakeFiles/runcompilecommands.dir/run_compile_commands.cxx.o

    Linking CXX executable runcompilecommands

    [100%] Built target runcompilecommands

    [root@localhost cmake-2.8.5]# gmake install

    [root@localhost cmake-2.8.5]# cd ..

    2)安装mysql

    [root@localhost src]# groupadd mysql

    [root@localhost src]# useradd -g mysql mysql

    [root@localhost src]# tar zxvf mysql-5.5.22.tar.gz

    [root@localhost src]# cd mysql-5.5.22

    [root@localhost mysql-5.5.22]#
    cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
    -DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
    -DDEFAULT_CHARSET=utf8 \
    -DDEFAULT_COLLATION=utf8_general_ci \
    -DWITH_EXTRA_CHARSETS:STRING=utf8,gbk \
    -DWITH_MYISAM_STORAGE_ENGINE=1 \
    -DWITH_INNOBASE_STORAGE_ENGINE=1 \
    -DWITH_MEMORY_STORAGE_ENGINE=1 \
    -DWITH_READLINE=1 \
    -DENABLED_LOCAL_INFILE=1 \
    -DMYSQL_DATADIR=/var/mysql/data \
    -DMYSQL_USER=mysql

    …… ……

    CMake Warning:

      Manually-specified variables were not used by the project:

        MYSQL_USER

        WITH_MEMORY_STORAGE_ENGINE

    -- Build files have been written to: /usr/local/src/mysql-5.5.22

    [root@localhost mysql-5.5.22]#make

    …… ……

    [100%] Building CXX object mysql-test/lib/My/SafeProcess/CMakeFiles/my_safe_process.dir/safe_process.cc.o

    Linking CXX executable my_safe_process

    [100%] Built target my_safe_process

    [root@localhost mysql-5.5.22]#make install

    …… ……

    -- Installing: /usr/local/mysql/man/man1/mysql_find_rows.1

    -- Installing: /usr/local/mysql/man/man1/mysql_upgrade.1

    -- Installing: /usr/local/mysql/man/man1/mysqlimport.1

    -- Installing: /usr/local/mysql/man/man1/mysql_client_test.1

    -- Installing: /usr/local/mysql/man/man8/mysqld.8

    [root@localhost mysql-5.5.22]# chmod +w /usr/local/mysql/

    [root@localhost mysql-5.5.22]# chown -R mysql:mysql /usr/local/mysql/

    [root@localhost mysql-5.5.22]# ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib/libmysqlclient.so.18

    [root@localhost mysql-5.5.22]# mkdir -p /var/mysql

    [root@localhost mysql-5.5.22]# mkdir -p /var/mysql/data/

    [root@localhost mysql-5.5.22]# mkdir -p /var/mysql/log/

    [root@localhost mysql-5.5.22]# chown -R mysql:mysql /var/mysql/

    [root@localhost mysql-5.5.22]# cd support-files/

    [root@localhost support-files]# cp my-medium.cnf /etc/my.cnf

    [root@localhost support-files]# cp mysql.server /etc/init.d/mysql

    初始化安装。

    [root@localhost support-files]# /usr/local/mysql/scripts/mysql_install_db \

    --defaults-file=/etc/my.cnf \

    --basedir=/usr/local/mysql \

    --datadir=/var/mysql/data \

    --user=mysql

    …… ……

    You can start the MySQL daemon with:

    cd /usr/local/mysql ; /usr/local/mysql/bin/mysqld_safe &

    You can test the MySQL daemon with mysql-test-run.pl

    cd /usr/local/mysql/mysql-test ; perl mysql-test-run.pl

    Please report any problems with the /usr/local/mysql/scripts/mysqlbug script!

    [root@localhost support-files]# chmod +x /etc/init.d/mysql

    [root@localhost support-files]# vi /etc/init.d/mysql

     basedir=/usr/local/mysql

     datadir=/var/mysql/data

    [root@localhost support-files]#chkconfig --add mysql

    [root@localhost support-files]#chkconfig --level 345 mysql on

    [root@localhost support-files]# cd /usr/local/mysql

    [root@localhost mysql]# service mysql start

    Starting MySQL.. SUCCESS!

    [root@localhost mysql]# mysql

    -bash: mysql: command not found

    [root@localhost mysql]# /usr/local/mysql/bin/mysql -uroot mysql

    Reading table information for completion of table and column names

    You can turn off this feature to get a quicker startup with -A

     

    Welcome to the MySQL monitor.  Commands end with ; or \g.

    Your MySQL connection id is 1

    Server version: 5.5.22 Source distribution

     

    Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.

     

    Oracle is a registered trademark of Oracle Corporation and/or its

    affiliates. Other names may be trademarks of their respective

    owners.

    Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

    mysql> show databases;

    +--------------------+

    | Database           |

    +--------------------+

    | information_schema |

    | mysql              |

    | performance_schema |

    | test               |

    +--------------------+

    4 rows in set (0.01 sec)

    mysql> exit

    Bye

    [root@localhost mysql]# ln -s /usr/local/mysql/bin/mysql /usr/bin

    [root@localhost mysql]# mysql

    Welcome to the MySQL monitor.  Commands end with ; or \g.

    Your MySQL connection id is 2

    Server version: 5.5.22 Source distribution

    Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.

    Oracle is a registered trademark of Oracle Corporation and/or its

    affiliates. Other names may be trademarks of their respective

    owners.

    Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

    mysql> show databases;

    +--------------------+

    | Database           |

    +--------------------+

    | information_schema |

    | mysql              |

    | performance_schema |

    | test               |

    +--------------------+

    4 rows in set (0.00 sec)

    mysql> grant all privileges on *.* to root@'%' identified by 'joy' with grant option;

    Query OK, 0 rows affected (0.00 sec)

    mysql> flush privileges;

    Query OK, 0 rows affected (0.00 sec)

    mysql> exit

    Bye

    [root@localhost mysql]# /etc/init.d/iptables stop;

    Flushing firewall rules: [  OK  ]

    Setting chains to policy ACCEPT: filter [  OK  ]

    Unloading iptables modules: [  OK  ]

    三、遇到的问题:

    ※ -bash: mysql: command not found

    原因:

    是因为mysql命令的路径在/usr/local/mysql/bin下面,所以你直接使用mysql命令时,系统在/usr/bin下面查此命令,所以找不到了。

    解决办法:做个链接即可。

    ln -s /usr/local/mysql/bin/mysql /usr/bin 

    ※ Could NOT find Curses (missing:  CURSES_LIBRARY CURSES_INCLUDE_PATH)

    错误重现:

    该错误会在安装cmake时发生,原因是以为没有执行第一步。当你执行完第一步重做cmake前需要先rm CMakeCache.txt。

    -- 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)

    ps:redhat上差不多,赚人气哈

  • 相关阅读:
    javascript 对象属性的添加,删除,json对象和字符串转换方法等
    利用jquery.form.js实现将form提交转为ajax方式提交的方法(带上传的表单提交)
    js封装的一行半显示省略号。(字数自由控制)
    jq和js中click 事件的几种方式总结和click事件的累加问题解决办法
    jquery $(document).ready() 与js原生的window.onload的区别总结
    jquery中attr和prop的区别
    织梦文档按权重排序
    织梦channelartlist标签内使用currentstyle
    dedecms无法下载远程jpeg图片 织梦不能提取文章内容中的jpeg图片生成缩略图
    织梦dedecms去除友情链接中的li和span
  • 原文地址:https://www.cnblogs.com/potu/p/2949369.html
Copyright © 2011-2022 走看看