zoukankan      html  css  js  c++  java
  • MySQL编译安装(MySQL5.5版本)

    安装依赖

    安装ncurses(5.9)  :  Ncurses 提供字符终端处理库,包括面板和菜单。它提供了一套控制光标,建立窗口,改变前景背景颜色以及处理鼠标操作的函数。使用户在字符终端下编写应用程序时绕过了那些恼人的底层机制。简而言之,他是一个可以使应用程序直接控制终端屏幕显示的函数库。

    ./configure --with-shared --without-debug --without-ada --enable-overwrite
    --without-ada参数为设定不编译为ada绑定,因进入chroot环境不能使用ada ;
    --enable-overwrite参数为定义把头文件安装到/tools/include下而不是/tools/include/ncurses目录
    --with-shared 生成共享库
    creating headers.sh
    

    ** Configuration summary for NCURSES 5.9 20110404:

     extended funcs: yes
     xterm terminfo: xterm</span>-<span style="color: #000000;">new
    
      bin directory: </span>/usr/<span style="color: #000000;">bin
      lib directory: </span>/usr/<span style="color: #000000;">lib
    

    include directory: /usr/include
    man directory: /usr/man
    terminfo directory:
    /usr/share/terminfo

    make
    ranlib ../lib/libncurses++.a
    /usr/bin/g++ -I../c++ -I../include -I. -DHAVE_CONFIG_H  -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64  -DNDEBUG -I. -I../include -O2  -fPIC -c ../c++/demo.cc -o ../obj_s/demo.o
    /usr/bin/g++  -o demo ../obj_s/demo.o -L../lib -lncurses++ -L../lib -lform -lmenu -lpanel -lncurses    -lutil   -Wl,-rpath,/lamp/ncurses-5.9/lib  -I../c++ -I../include -I. -DHAVE_CONFIG_H  -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64  -DNDEBUG -I. -I../include -O2  -fPIC 
    make[1]: Leaving directory `/lamp/ncurses-5.9/c++'
    make install
    make[1]: Entering directory `/lamp/ncurses-5.9/c++'
    /usr/bin/install -c -m 644 ../lib/libncurses++.a /usr/lib/libncurses++.a
    installing ./cursesapp.h in /usr/include
    installing ./cursesf.h in /usr/include
    installing ./cursesm.h in /usr/include
    installing ./cursesp.h in /usr/include
    installing ./cursesw.h in /usr/include
    installing ./cursslk.h in /usr/include
    installing etip.h in /usr/include
    make[1]: Leaving directory `/lamp/ncurses-5.9/c++'

    安装 cmake(2.8.8) : mysql在5.5以后,不再使用./configure工具,进行编译安装。而使用cmake工具替代了./configure工具。cmake的具体用法参考文档cmake说明。

     ./configure
    CMake has bootstrapped.  Now run gmake.
    gmake
    [100%] Building CXX object Tests/CMakeLib/CMakeFiles/runcompilecommands.dir/run_compile_commands.cxx.o
    Linking CXX executable runcompilecommands
    [100%] Built target runcompilecommands
    Scanning dependencies of target foo
    [100%] Building CXX object Tests/FindPackageModeMakefileTest/CMakeFiles/foo.dir/foo.cpp.o
    Linking CXX static library libfoo.a
    [100%] Built target foo
    gmake install
    -- Installing: /usr/local/doc/cmake-2.8/ctest.txt
    -- Installing: /usr/local/doc/cmake-2.8/ctest.docbook
    -- Installing: /usr/local/doc/cmake-2.8/cpack.txt
    -- Installing: /usr/local/doc/cmake-2.8/cpack.docbook
    -- Installing: /usr/local/doc/cmake-2.8/ccmake.txt
    -- Installing: /usr/local/doc/cmake-2.8/ccmake.docbook
    -- Installing: /usr/local/share/aclocal/cmake.m4

     添加用户组,将mysql用户加入mysql组

     groupadd mysql
     useradd mysql -s /sbin/nologin -M -g mysql

    编译mysql

    cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci    -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_TCP_PORT=3306
    -DCMAKE_INSTALL_PREFIX=/usr/local/mysql 安装位置
    -DMYSQL_UNIX_ADDR=/tmp/mysql.sock 指定socket(套接字)文件位置
    -DEXTRA_CHARSETS=all 扩展字符支持
    -DDEFAULT_CHARSET=utf8     默认字符集
    -DDEFAULT_COLLATION=utf8_general_ci     默认字符校对
    -DWITH_MYISAM_STORAGE_ENGINE=1    安装myisam存储引擎
    -DWITH_INNOBASE_STORAGE_ENGINE=1     安装innodb存储引擎
    -DWITH_READLINE=1     支持readline库
    -DENABLED_LOCAL_INFILE=1    启用加载本地数据
    -DMYSQL_TCP_PORT=3306 指定mysql端口
    -- MySQL 5.5.23
    -- Packaging as: mysql-5.5.23-Linux-i686
    -- Configuring done
    -- Generating done
    -- Build files have been written to: /lamp/mysql-5.5.23

    安装mysql

    make && make install
    -- Installing: /usr/local/mysql/man/man1/mysqldumpslow.1
    -- Installing: /usr/local/mysql/man/man1/mysql_waitpid.1
    -- Installing: /usr/local/mysql/man/man8/mysqld.8

    修改目录权限

    [root@localhost mysql]# cd /usr/local/mysql/
    [root@localhost mysql]# ls
    bin      data  include         lib  mysql-test  scripts  sql-bench
    COPYING  docs  INSTALL-BINARY  man  README      share    support-files
    [root@localhost mysql]# chown -R mysql .
    [root@localhost mysql]# chgrp -R mysql .
    [root@localhost mysql]# chown -R root .
    [root@localhost mysql]# chown -R mysql data

    创建数据库授权表,初始化数据库

    [root@localhost mysql]# /usr/local/mysql/scripts/mysql_install_db --user=mysql
    Installing MySQL system tables...
    OK
    Filling help tables...
    OK
    

    To start mysqld at boot time you have to copy
    support
    -files/mysql.server to the right place for your system

    PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
    To
    do so, start the server, then issue the following commands:

    ./bin/mysqladmin -u root password 'new-password'
    .
    /bin/mysqladmin -u root -h localhost.localdomain password 'new-password'

    Alternatively you can run:
    ./bin/mysql_secure_installation

    which will also give you the option of removing the test
    databases and anonymous user created by default. This is
    strongly recommended
    for production servers.

    See the manual for more instructions.

    You can start the MySQL daemon with:
    cd . ; ./bin/mysqld_safe &

    You can test the MySQL daemon with mysql-test-run.pl
    cd .
    /mysql-test ; perl mysql-test-run.pl

    Please report any problems with the ./bin/mysqlbug script!

    复制mysql配置文件

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

    开机自启

    vi /etc/rc.local
    /usr/local/mysql/bin/mysqld_safe --user=mysql &

    源码方式启动

    /usr/local/mysql/bin/mysqld_safe --user=mysql &

      /usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf --user=mysql &  #另一种

    设置mysql密码

    /usr/local/mysql/bin/mysqladmin -u root password '123'

    登陆

     /usr/local/mysql/bin/mysql -u root -p

     

  • 相关阅读:
    Majority Element
    Longest Increasing Subsequence
    Count Primes
    Valid Parentheses
    Largest Rectangle in Histogram
    Linked List Cycle II
    Linked List Cycle
    Evaluate Reverse Polish Notation
    Longest Valid Parentheses
    适配总结
  • 原文地址:https://www.cnblogs.com/yhq-qhh/p/10506187.html
Copyright © 2011-2022 走看看