mysql的安装问题 --- 1

mysql-5.1.72.zip

   ”学习要用英文文档,使用要用中文文档。“
   “水平有限,请大家带着批判的态度对待,可不能因为我的错误影响到你。”
   "觉得最好的资料莫过于README & INSTALL*" ———— 一家之言
   “文中出现的数字代表在源文件中的行数,保留的意思方便你查看,并且对我debug。”
   “文中的翻译,是我对计算机世界英文的理解,不一定是英文原意,就是说,是有个人理解的成分,这就是个水平问题了,欢迎指正。”
                           itxiaocui@163.com

   “因为上传的原因,我的文档在linux系统写的,所以加了后缀。你知道的,……”
-------------------
二进制包详细安装过程

   956 创建用户和组

   如果系统(OS)中没有用户(mysql),就需要自行创建;在安装和运行的时候需要一个安全的用户。
   这个用户的作用仅仅在于软件运行时的权限管理,不许要该用户登录系统(OS);“-r”选项将创建无法登录系统的用户

       shell> groupadd mysql
       shell> useradd -r -g mysql mysql

   安装在以下目录中进行,确保你现在使用的用户在这个目录下有一定的权限;如果没用的话,就是“root”登场的时候。
   创建安装目录、并为这个目录创建一个符号链接。
          shell> cd /usr/local
       shell> tar -xf /home/sunny/mysql-5.1.72.tar.gz        ( 和下边的的加压是一回事,解压不同的包而已;这行是发行包的原版 )

   如果上边的tar包无法执行(原因是tar命令无法调用“z”选项)
   shell> gunzip < /home/sunny/mysql-5.1.72.tar.gz | tar xvf -        ( 我习惯去掉最后[xvf]中的“v”;…… )

   shell> unzip /home/sunny/mysql-5.1.72.zip        ( 这行是我使用的包的解压命令语句;尊重原版的考虑保留上边命令 )

       shell> ln -s /usr/local/mysql-5.1.72 mysql

       shell> cd mysql
       shell> chown -R mysql.mysql .
       shell> scripts/mysql_install_db --user=mysql
       shell> chown -R root .
       shell> chown -R mysql data
       # 使用模板创建配置文件
       shell> cp support-files/my-medium.cnf /etc/my.cnf
       shell> bin/mysqld_safe --user=mysql &
       # 创建chkconfig脚本
       shell> cp support-files/mysql.server /etc/init.d/mysql.server

-------------------
源码包安装
   准确地讲,在下边的系统上安装都算是源码包安装,我这里使用的系统是CentOS 6.4,把概念缩小了;下边系统的安装同样在包文档中能找到。
       4551 2.6. Installing MySQL on Solaris and OpenSolaris
       4757 2.7. Installing MySQL on IBM AIX
       4780 2.8. Installing MySQL on HP-UX
       4864 2.9. Installing MySQL on FreeBSD
       4921 2.10. Installing MySQL on i5/OS

   源码包安装允许你自行决定编译进最终程序的参数、选项、和安装位置。使用源码包编译安装,你的系统需要一些工具程序:解压程序,GCC 3.4.6或以后版本。windows下需要Visual Studio 2005(8.0)或以后,或者其他众所周知的编译器均可(编译器支持ANSI标准)。make 3.75或以后版本和libtool 1.5.24或以后版本程序的“有的干活”。autoconf 2.58(或以后版本)。m4和bison……
   * 本文,不包括开发版本的安装方法。

   默认情况下,当你直接配置编译程序的时候,程序最终将会安装在目录“/usr/local”。源码默认安装时,跟二进制安装的目录结构是不同的。
   服务程序            libexec            bin
   数据文件            var            data
   mysql_install_db    bin            scripts
   头文件 库文件        include/mysql        lib/mysql

  5315    安装过程
   * 详见二进制部分说明
       # 准备工作
       shell> groupadd mysql
       shell> useradd -g mysql mysql
       # 上演哪
       shell> tar -xf mysql-5.1.72.tar.gz
       shell> cd mysql-5.1.72
       shell> ./configure --prefix=/usr/local/mysql
       shell> make
       shell> make install        ( 这一步需要“root”身份执行 )
       # 构建结束

       # 安装后的设置
       shell> cd /usr/local/mysql
       shell> chown -R mysql .
       shell> chgrp -R mysql .
       shell> bin/mysql_install_db --user=mysql
       shell> chown -R root .
       shell> chown -R mysql var
       # 创建配置文件;启动测试
       shell> cp support-files/my-medium.cnf /etc/my.cnf
       shell> bin/mysqld_safe --user=mysql &
   shell> ps aux | grep mysqld
   shell> netstat -nltp
       # 创建chkconfig脚本
  5338 shell> cp support-files/mysql.server /etc/init.d/mysql.server

-------------------
  5840      * To compile just the MySQL client libraries and client programs
  5841        and not the server, use the --without-server option:

仅仅编译客户端程序(包括所需的库文件)

  5842 shell> ./configure --without-server

  5852      * To build the embedded MySQL library (libmysqld.a), use the
  5853        --with-embedded-server option.

  5852      * 构建嵌入式库(libmysqld.a)        (* 我现在没有搞懂这个嵌入式库,是不是就是共享库;猜想是;前边的翻译为慎重起见。)
  5853        --with-embedded-server option.
   shell> ./configure --with-embedded-server

               [root@hhh mysql-5.1.72]# find / -name libmysqld.a
               [root@hhh mysql-5.1.72]#
               我安装过服务器版本后,这一项的库是没有的。
定制程序安装的

   shell> mkdir /data_mysql
   shell> mount /dev/sdd/5 /data_mysql
   shell> mkdir /data_mysql/zg_blog
   shell> ./configure --prefix=/usr/local/mysql --localstatedir=/data_mysql/zg_blog

更改监听端口

   shell> ./configure --with-tcp-port=3307

指定MySQL socket文件(套接子文件)位置

   shell> ./configure --with-unix-socket-path=/usr/local/mysql/tmp/mysql.sock

编译静态链接文件(以获取更佳的性能)

   shell> ./configure --with-client-ldflags=-all-static --with-mysqld-ldflags=-all-static

   * 节选配置帮助
   ./configure --help > help.read4me
   vi help.read4me
   /ldflags
   --with-mysqld-ldflags   Extra linking arguments for mysqld
   --with-client-ldflags   Extra linking arguments for clients

选择c++编译器

  5898      * If you are using gcc and do not have libg++ or libstdc++
              installed, you can tell configure to use gcc as your C++
              compiler:
       shell> CC=gcc CXX=gcc ./configure
   老版本(编译器)里不这样设定,会报奇怪的错误。

   5906        In most cases, you can get a reasonably optimized MySQL binary
   5907        by using the following options on the configure line:

为了获得一个更加“优质”(性能)的mysqld。

   shell> ./configure --prefix=/usr/local/mysql --enable-assembler --with-mysqld-ldflags=-all-static

       shell> CFLAGS="-O3 -mpentiumpro" CXX=gcc CXXFLAGS="-O3 -mpentiumpro \
           -felide-constructors -fno-exceptions -fno-rtti" ./configure \
           --prefix=/usr/local/mysql --enable-assembler \
           --with-mysqld-ldflags=-all-static

   * MySQL的文档介绍到这里,很显然是担心我们使用者,看偏了官网提供的二进制(编译好的)包,专门说明一下,那个二进制包也是经过全面优化
   而且能很好地适应大多数用户。


   * linker not being able to create the shared library
              libmysqlclient.so.N (where N is a version number), you can
              work around this problem by giving the --disable-shared option
              to configure. In this case, configure does not build a shared
              libmysqlclient.so.N library.
   如果报错不能创建共享库(libmysqlclient.so.N *),就使用选项取消创建共享库
   shell> ./configure --disable-shared

数据库的字符集选择

   默认字符集是latin1(cp1252 West European),修改如下:
   shell> ./configure --with-charset=
      5932        CHARSET may be one of binary, armscii8, ascii, big5, cp1250,
      5933        cp1251, cp1256, cp1257, cp850, cp852, cp866, cp932, dec8,
      5934        eucjpms, euckr, gb2312, gbk, geostd8, greek, hebrew, hp8,
      5935        keybcs2, koi8r, koi8u, latin1, latin2, latin5, latin7, macce,
      5936        macroman, sjis, swe7, tis620, ucs2, ujis, utf8. (Additional
      5937        character sets might be available. Check the output from
      5938        ./configure --help for the current list.)

修改排序规则

   默认排序规则是latin1_swedish_ci,同样可以自行修改:
   shell> ./configure --with-collation=

   排序规则依赖与字符集;这里说依赖,是因为装过软件甚为其扰,故此在这里这么讲有助于你的理解。
   shell> mysql -uroot -hlocalhost -p
   mysql> show collation        ( 看,这么确定“依赖”关系 )

   文档说是使用空格,我使用的是“,”;
   shell> ./configure --with-extra-charset=gbk,gb2312,utf8
   shell> ./configure --with-extra-charset=all        ( 不能被动态加载的统统编译;你觉得这样做的必要性! )

配置主程序支持代码调试

   shell> ./configure --with-debug        ( 关于这个选项的英文翻译我看得不大明白;文档5962行 )
   一般情况下,由于这个选项产生的输出信息显示在错误“日志”中。
   * 该选项被选中时,默认开启下边的选项;除非明确关闭(--disable-debug-sync)。

   要让服务带有同步调试功能,使用下面的选项。这个选项用来测试、调试程序(感觉在括号前边应该有个什么词,才能完全表达这句英文的意思)。
   当着个选项被编译进服务,运行程序时,默认还是不执行的。在运行程序还要加上一个选项。
   shell> ./configure --enable-debug-sync
   shell> mysqld_safe --debug-sync-timeout=N        ( N 默认是0,要激活功能,必须大于0; )

安安宁宁地使用线程

   编译客户端程序时,如果需要使用线程时,请使用这个选项。
   shell> ./configure --without-server --enable-thread-safe-client

支持压缩

   该选项提供压缩支持。
   shell> ./configure --with-zlib-dir=no|bundled|DIR

大数据表支持

   资料显示行数能打到 3.401579607192 * 10的38次方。( 没实践过,有点心虚;6017行 )
   shell> ./configure --with-big-tables

XXX

   这一项的翻译,我不是很懂的意思(有待提高啊)。
   --disable-grant-options使得--bootstrap --skip-grant-tables --init-file失效。
   shell> ./configure --disable-grant-options

插件

   插件可以动态编译、也可以静态编译(有些受限制)。“--with”和“--without”同时出现,“--without”优先级高。
   一些插件(* )没有明确选择、明确拒绝,如果该插件支持动态调用,将被默认动态编译。不支持动态调用的就没有被编译进去(该出现在*号后边)。
   有点多,在./configure --help中搜索"plugin"

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

解决配置编译时的错误信息

   所有 MySQL 使用 gcc 程序在 Solaris 或者 Linux 下编译均正常;在其他系统中,可能存在调用报错问题。
   * 当一次配置(./configure)时报错,你使用一定的方法解决后,再次配置,依然报错。那么可能是这个文件的缘故,它记录了之前的错误,在
     第二次配置时,配置脚本查看该文件导致“错误性”报错。(文件名:config.cache)
   * 当你第二次配置后,可能需要清楚之前的目标文件,因为再一次执行 make 时,因为目标文件存在,所以不再编译该目标文件。但是,配置选项
     改变后,导致“编译”出意外的目标文件。……

   shell> rm config.cache
   shell> make clean
   当然你还可以:
   shell> make distclean        ( 这个在编译内核时,你可能遇到 )

   * 当编译(make)时,发生这么个错误,说明:你可能已经耗尽内存或者交换分区。不用多讲吧,是 gcc 编译时需要很大的内存。
     这个问题还有可能发生在你的硬件配置很牛的情况下,请你试着按照下边的方式执行配置后再次编译。
     compiling sql_yacc.cc
     Internal compiler error: program cclplus got fatal signal 11
   shell> ./configure --with-low-memory

   * 默认情况下,配置程序调用 c++ 作为编译标志调用相应库文件;可同时,你使用的是 gcc 编译器,可能会发出错误信息。如下:
     configure: error: installation or configuration problem:
     C++ compiler cannot create executables.
     一旦出现这个现象,你可能没有 g++ ,或者有 g++ ,没有 libg++ 、 libstdc++ 。可以查看 config.log ,会告知为什么 C++
     编译器没有工作。这个问题可以通过设置环境变量解决,如下:
   shell> CXX="gcc -03" ./configure
     这样会使得 gcc 编译 C++ 源文档像 g++ 一样出色(这样做,默认不调用 libg++ or libstdc++ )。当然这个问题的解决,可以
     使用安装(*很明确,不用写出来吧)的方法来解决,之所以 MySQL 没有建议安装,是因为这样做了只会增加了 mysqld 的大小,而
     没有其他的优势引入。
     (过去的某些版本,不得以使用安装的方法解决,确实是个奇怪的问题。———— 这句是原文中的,觉得老外蛮有意思的)
   * 指定编译器标志(编译器名字),eg:
   shell> CC=gcc
   shell> CFLAGS=-03
   shell> CXX=gcc
   shell> CXXFLAGS=-03
   shell> export CC CFLAGS CXX CXXFLAGS
   在这个地方有段英文,我明白英文表达的意思,可是不知到怎么运用;故此,保留原始说明(6174)。
          6174        To see what flags you might need to specify, invoke
          6175        mysql_config with the --cflags option.
.......................................................................
[root@hhh scripts]# file mysql_config
mysql_config: POSIX shell script text executable
[root@hhh scripts]# ./mysql_config --cflags
-I/opt/mysql-5.1.72/include/mysql  -g -DUNIV_LINUX -DUNIV_LINUX
[root@hhh scripts]# ./mysql_config
Usage: ./mysql_config [OPTIONS]
Options:
       --cflags         [-I/opt/mysql-5.1.72/include/mysql  -g -DUNIV_LINUX -DUNIV_LINUX]
       --include        [-I/opt/mysql-5.1.72/include/mysql]
       --libs           [-rdynamic -L/opt/mysql-5.1.72/lib/mysql -lmysqlclient -lz -lcrypt -lnsl -lm]
       --libs_r         [-rdynamic -L/opt/mysql-5.1.72/lib/mysql -lmysqlclient_r -lz -lpthread -lcrypt -lnsl -lm -lpthread]
       --plugindir      [/opt/mysql-5.1.72/lib/mysql/plugin]
       --socket         [/tmp/mysql.sock]
       --port           [0]
       --version        [5.1.72]
       --libmysqld-libs [-rdynamic -L/opt/mysql-5.1.72/lib/mysql -lmysqld -ldl -lz -lpthread -lcrypt -lnsl -lm -lpthread -lrt]
[root@hhh scripts]#
.......................................................................


本文出自 “小崔的实验笔记” 博客,谢绝转载!

mysql的安装问题 --- 1,布布扣,bubuko.com

mysql的安装问题 --- 1

上一篇:不同版本的SQL Server之间数据导出导入的方法及性能比较


下一篇:windows batch cmd 批处理命令之 系统内置变量