【MySQL学习笔记】CentOS 6.6上源码编译方式安装MySQL 5.6

前端之家收集整理的这篇文章主要介绍了【MySQL学习笔记】CentOS 6.6上源码编译方式安装MySQL 5.6前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

一、安装源码编译配置工具:cmake

先下载cmake工具的源代码

  1. [root@ggg2 Desktop]# wget http://www.cmake.org/files/v2.8/cmake-2.8.4.tar.gz
  2. --2016-08-21 22:09:21-- http://www.cmake.org/files/v2.8/cmake-2.8.4.tar.gz
  3. Resolving www.cmake.org... 66.194.253.19
  4. Connecting to www.cmake.org|66.194.253.19|:80... connected.
  5. HTTP request sent,awaiting response... 301 Moved Permanently
  6. Location: http://cmake.org/files/v2.8/cmake-2.8.4.tar.gz [following]
  7. --2016-08-21 22:09:22-- http://cmake.org/files/v2.8/cmake-2.8.4.tar.gz
  8. Resolving cmake.org... 66.194.253.19
  9. Connecting to cmake.org|66.194.253.19|:80... connected.
  10. HTTP request sent,awaiting response... 301 Moved Permanently
  11. Location: https://cmake.org/files/v2.8/cmake-2.8.4.tar.gz [following]
  12. --2016-08-21 22:09:23-- https://cmake.org/files/v2.8/cmake-2.8.4.tar.gz
  13. Connecting to cmake.org|66.194.253.19|:443... connected.
  14. HTTP request sent,awaiting response... 200 OK
  15. Length: 5477628 (5.2M) [application/x-gzip]
  16. Saving to: cmake-2.8.4.tar.gz
  17.  
  18. 100%[=========================================================>] 5,477,628 101K/s in 63s
  19.  
  20. 2016-08-21 22:10:27 (84.8 KB/s) - cmake-2.8.4.tar.gz saved [5477628/5477628]

然后切换目录,进行 配置,需要注意的是 ./configure 是源码安装的很重要的一步,对要安装的软件进行配置,检查当前的环境是否满足要安装软件的依赖关系:
  1. [root@ggg2 Desktop]# cd cmake-2.8.4
  2. [root@ggg2 cmake-2.8.4]# ./configure
  3. ---------------------------------------------
  4. CMake 2.8.4,Copyright 2000-2009 Kitware,Inc.
  5. ---------------------------------------------
  6. Error when bootstrapping CMake:
  7. Cannot find appropriate C compiler on this system.
  8. Please specify one using environment variable CC.
  9. See cmake_bootstrap.log for compilers attempted.
  10.  
  11. ---------------------------------------------
  12. Log of errors: /root/Desktop/cmake-2.8.4/Bootstrap.cmk/cmake_bootstrap.log
  13. ---------------------------------------------
  1. ---------------------------------------------
  2. CMake 2.8.4,Inc.
  3. C compiler on this system is: cc
  4. ---------------------------------------------
  5. Error when bootstrapping CMake:
  6. Cannot find appropriate C++ compiler on this system.
  7. Please specify one using environment variable CXX.
  8. See cmake_bootstrap.log for compilers attempted.
  9. ---------------------------------------------
  10. Log of errors: /root/Desktop/cmake-2.8.4/Bootstrap.cmk/cmake_bootstrap.log
  11. ---------------------------------------------

从上面的输出,发现是报错了,仔细查看报错信息,发现是 没有找到合适的c、c++编译器,所以接下来要安装编译器:
  1. [root@ggg2 ~]# yum -y install gcc
  2. Loaded plugins: fastestmirror,refresh-packagekit,security
  3. Setting up Install Process
  4. Loading mirror speeds from cached hostfile
  5. * base: centos.ustc.edu.cn
  6. * extras: ftp.sjtu.edu.cn
  7. * updates: centos.ustc.edu.cn
  8. Resolving Dependencies
  9. --> Running transaction check
  10. ---> Package gcc.x86_64 0:4.4.7-17.el6 will be installed
  11. --> Processing Dependency: libgomp = 4.4.7-17.el6 for package: gcc-4.4.7-17.el6.x86_64
  12. --> Processing Dependency: cpp = 4.4.7-17.el6 for package: gcc-4.4.7-17.el6.x86_64
  13. --> Processing Dependency: libgcc >= 4.4.7-17.el6 for package: gcc-4.4.7-17.el6.x86_64
  14. --> Processing Dependency: cloog-ppl >= 0.15 for package: gcc-4.4.7-17.el6.x86_64
  15. --> Running transaction check
  16. ---> Package cloog-ppl.x86_64 0:0.15.7-1.2.el6 will be installed
  17. --> Processing Dependency: libppl_c.so.2()(64bit) for package: cloog-ppl-0.15.7-1.2.el6.x86_64
  18. --> Processing Dependency: libppl.so.7()(64bit) for package: cloog-ppl-0.15.7-1.2.el6.x86_64
  19. ---> Package cpp.x86_64 0:4.4.7-17.el6 will be installed
  20. --> Processing Dependency: libmpfr.so.1()(64bit) for package: cpp-4.4.7-17.el6.x86_64
  21. ---> Package libgcc.x86_64 0:4.4.7-11.el6 will be updated
  22. ---> Package libgcc.x86_64 0:4.4.7-17.el6 will be an update
  23. ---> Package libgomp.x86_64 0:4.4.7-11.el6 will be updated
  24. ---> Package libgomp.x86_64 0:4.4.7-17.el6 will be an update
  25. --> Running transaction check
  26. ---> Package mpfr.x86_64 0:2.4.1-6.el6 will be installed
  27. ---> Package ppl.x86_64 0:0.10.2-11.el6 will be installed
  28. --> Finished Dependency Resolution
  29.  
  30. Dependencies Resolved
  31.  
  32. ================================================================================
  33. Package Arch Version Repository Size
  34. ================================================================================
  35. Installing:
  36. gcc x86_64 4.4.7-17.el6 base 10 M
  37. Installing for dependencies:
  38. cloog-ppl x86_64 0.15.7-1.2.el6 base 93 k
  39. cpp x86_64 4.4.7-17.el6 base 3.7 M
  40. mpfr x86_64 2.4.1-6.el6 base 157 k
  41. ppl x86_64 0.10.2-11.el6 base 1.3 M
  42. Updating for dependencies:
  43. libgcc x86_64 4.4.7-17.el6 base 103 k
  44. libgomp x86_64 4.4.7-17.el6 base 134 k
  45.  
  46. Transaction Summary
  47. ================================================================================
  48. Install 5 Package(s)
  49. Upgrade 2 Package(s)
  50.  
  51. Total size: 16 M
  52. Downloading Packages:
  53. warning: rpmts_HdrFromFdno: Header V3 RSA/SHA1 Signature,key ID c105b9de: NOKEY
  54. Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
  55. Importing GPG key 0xC105B9DE:
  56. Userid : CentOS-6 Key (CentOS 6 Official Signing Key) <centos-6-key@centos.org>
  57. Package: centos-release-6-6.el6.centos.12.2.x86_64 (@anaconda-CentOS-201410241409.x86_64/6.6)
  58. From : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
  59. Running rpm_check_debug
  60. Running Transaction Test
  61. Transaction Test Succeeded
  62. Running Transaction
  63. Updating : libgcc-4.4.7-17.el6.x86_64 1/9
  64. Installing : ppl-0.10.2-11.el6.x86_64 2/9
  65. Installing : cloog-ppl-0.15.7-1.2.el6.x86_64 3/9
  66. Updating : libgomp-4.4.7-17.el6.x86_64 4/9
  67. Installing : mpfr-2.4.1-6.el6.x86_64 5/9
  68. Installing : cpp-4.4.7-17.el6.x86_64 6/9
  69. Installing : gcc-4.4.7-17.el6.x86_64 7/9
  70. Cleanup : libgomp-4.4.7-11.el6.x86_64 8/9
  71. Cleanup : libgcc-4.4.7-11.el6.x86_64 9/9
  72. Verifying : libgcc-4.4.7-17.el6.x86_64 1/9
  73. Verifying : ppl-0.10.2-11.el6.x86_64 2/9
  74. Verifying : gcc-4.4.7-17.el6.x86_64 3/9
  75. Verifying : mpfr-2.4.1-6.el6.x86_64 4/9
  76. Verifying : libgomp-4.4.7-17.el6.x86_64 5/9
  77. Verifying : cpp-4.4.7-17.el6.x86_64 6/9
  78. Verifying : cloog-ppl-0.15.7-1.2.el6.x86_64 7/9
  79. Verifying : libgcc-4.4.7-11.el6.x86_64 8/9
  80. Verifying : libgomp-4.4.7-11.el6.x86_64 9/9
  81.  
  82. Installed:
  83. gcc.x86_64 0:4.4.7-17.el6
  84.  
  85. Dependency Installed:
  86. cloog-ppl.x86_64 0:0.15.7-1.2.el6 cpp.x86_64 0:4.4.7-17.el6
  87. mpfr.x86_64 0:2.4.1-6.el6 ppl.x86_64 0:0.10.2-11.el6
  88.  
  89. Dependency Updated:
  90. libgcc.x86_64 0:4.4.7-17.el6 libgomp.x86_64 0:4.4.7-17.el6
  91.  
  92. Complete!
  1. [root@ggg2 cmake-2.8.4]# yum -y install gcc-c++
  2. Loaded plugins: fastestmirror,security
  3. Setting up Install Process
  4. Loading mirror speeds from cached hostfile
  5. * base: centos.ustc.edu.cn
  6. * extras: ftp.sjtu.edu.cn
  7. * updates: centos.ustc.edu.cn
  8. Resolving Dependencies
  9. --> Running transaction check
  10. ---> Package gcc-c++.x86_64 0:4.4.7-17.el6 will be installed
  11. --> Processing Dependency: libstdc++-devel = 4.4.7-17.el6 for package: gcc-c++-4.4.7-17.el6.x86_64
  12. --> Processing Dependency: libstdc++ = 4.4.7-17.el6 for package: gcc-c++-4.4.7-17.el6.x86_64
  13. --> Running transaction check
  14. ---> Package libstdc++.x86_64 0:4.4.7-11.el6 will be updated
  15. ---> Package libstdc++.x86_64 0:4.4.7-17.el6 will be an update
  16. ---> Package libstdc++-devel.x86_64 0:4.4.7-17.el6 will be installed
  17. --> Finished Dependency Resolution
  18.  
  19. Dependencies Resolved
  20.  
  21. ===================================================================================================
  22. Package Arch Version Repository Size
  23. ===================================================================================================
  24. Installing:
  25. gcc-c++ x86_64 4.4.7-17.el6 base 4.7 M
  26. Installing for dependencies:
  27. libstdc++-devel x86_64 4.4.7-17.el6 base 1.6 M
  28. Updating for dependencies:
  29. libstdc++ x86_64 4.4.7-17.el6 base 295 k
  30.  
  31. Transaction Summary
  32. ===================================================================================================
  33. Install 2 Package(s)
  34. Upgrade 1 Package(s)
  35.  
  36. Total download size: 6.6 M
  37. Downloading Packages:
  38. (1/3): gcc-c++-4.4.7-17.el6.x86_64.rpm | 4.7 MB 00:21
  39. (2/3): libstdc++-4.4.7-17.el6.x86_64.rpm | 295 kB 00:00
  40. (3/3): libstdc++-devel-4.4.7-17.el6.x86_64.rpm | 1.6 MB 00:11
  41. ---------------------------------------------------------------------------------------------------
  42. Total 195 kB/s | 6.6 MB 00:34
  43. Running rpm_check_debug
  44. Running Transaction Test
  45. Transaction Test Succeeded
  46. Running Transaction
  47. Updating : libstdc++-4.4.7-17.el6.x86_64 1/4
  48. Installing : libstdc++-devel-4.4.7-17.el6.x86_64 2/4
  49. Installing : gcc-c++-4.4.7-17.el6.x86_64 3/4
  50. Cleanup : libstdc++-4.4.7-11.el6.x86_64 4/4
  51. Verifying : gcc-c++-4.4.7-17.el6.x86_64 1/4
  52. Verifying : libstdc++-4.4.7-17.el6.x86_64 2/4
  53. Verifying : libstdc++-devel-4.4.7-17.el6.x86_64 3/4
  54. Verifying : libstdc++-4.4.7-11.el6.x86_64 4/4
  55.  
  56. Installed:
  57. gcc-c++.x86_64 0:4.4.7-17.el6
  58.  
  59. Dependency Installed:
  60. libstdc++-devel.x86_64 0:4.4.7-17.el6
  61.  
  62. Dependency Updated:
  63. libstdc++.x86_64 0:4.4.7-17.el6
  64.  
  65. Complete!

安装完成后,可以查看一下c编译器的版本:
  1. [root@ggg2 ~]# gcc --version
  2. gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-17)
  3. Copyright (C) 2010 Free Software Foundation,Inc.
  4. This is free software; see the source for copying conditions. There is NO
  5. warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

然后,再次尝试配置,且进行编译、安装:
  1. [root@ggg2 cmake-2.8.4]# ./configure
  2. 此处省略1w
  3.  
  4. [root@ggg2 cmake-2.8.4]# gmake && make install
  5. 此处省略1k
至此,cmake工具安装完成, 不容易啊


二、修改MysqL用户的限制

主要是在 /etc/security/limits.conf 文件的最后,加上4行,这4行主要是设置MysqL用户,能打开的文件个数、能打开的进程数:

  1. MysqL soft nproc 2047
  2. MysqL hard nproc 16384
  3. MysqL soft nofile 1024
  4. MysqL hard nofile 65536
  1. [root@ggg2 Desktop]# cat /etc/security/limits.conf
  2. # /etc/security/limits.conf
  3. #
  4. #Each line describes a limit for a user in the form:
  5. #
  6. #<domain> <type> <item> <value>
  7. #
  8. #Where:
  9. #<domain> can be:
  10. # - a user name
  11. # - a group name,with @group Syntax
  12. # - the wildcard *,for default entry
  13. # - the wildcard %,can be also used with %group Syntax,# for maxlogin limit
  14. #
  15. #<type> can have the two values:
  16. # - "soft" for enforcing the soft limits
  17. # - "hard" for enforcing hard limits
  18. #
  19. #<item> can be one of the following:
  20. # - core - limits the core file size (KB)
  21. # - data - max data size (KB)
  22. # - fsize - maximum filesize (KB)
  23. # - memlock - max locked-in-memory address space (KB)
  24. # - nofile - max number of open file descriptors
  25. # - RSS - max resident set size (KB)
  26. # - stack - max stack size (KB)
  27. # - cpu - max cpu time (MIN)
  28. # - nproc - max number of processes
  29. # - as - address space limit (KB)
  30. # - maxlogins - max number of logins for this user
  31. # - maxsyslogins - max number of logins on the system
  32. # - priority - the priority to run user process with
  33. # - locks - max number of file locks the user can hold
  34. # - sigpending - max number of pending signals
  35. # - msgqueue - max memory used by POSIX message queues (bytes)
  36. # - nice - max nice priority allowed to raise to values: [-20,19]
  37. # - rtprio - max realtime priority
  38. #
  39. #<domain> <type> <item> <value>
  40. #
  41.  
  42. #* soft core 0
  43. #* hard RSS 10000
  44. #@student hard nproc 20
  45. #@faculty soft nproc 20
  46. #@faculty hard nproc 50
  47. #ftp hard nproc 0
  48. #@student - maxlogins 4
  49.  
  50. MysqL soft nproc 2047
  51. MysqL hard nproc 16384
  52. MysqL soft nofile 1024
  53. MysqL hard nofile 65536
  54.  
  55. # End of file

三、下载MysqL代码,解压
  1. [root@ggg2 Desktop]# wget http://dev.MysqL.com/get/Downloads/MysqL-5.6/MysqL-5.6.12.tar.gz
  2. --2016-08-21 23:01:28-- http://dev.MysqL.com/get/Downloads/MysqL-5.6/MysqL-5.6.12.tar.gz
  3. Resolving dev.MysqL.com... 137.254.60.11
  4. Connecting to dev.MysqL.com|137.254.60.11|:80... connected.
  5. HTTP request sent,awaiting response... 302 Found
  6. Location: http://cdn.MysqL.com//archives/MysqL-5.6/MysqL-5.6.12.tar.gz [following]
  7. --2016-08-21 23:01:29-- http://cdn.MysqL.com//archives/MysqL-5.6/MysqL-5.6.12.tar.gz
  8. Resolving cdn.MysqL.com... 23.77.240.248
  9. Connecting to cdn.MysqL.com|23.77.240.248|:80... connected.
  10. HTTP request sent,awaiting response... 200 OK
  11. Length: 35874671 (34M) [application/x-tar-gz]
  12. Saving to: MysqL-5.6.12.tar.gz
  13.  
  14. 100%[=========================================================>] 35,874,671 504K/s in 72s
  15.  
  16. 2016-08-21 23:02:41 (487 KB/s) - MysqL-5.6.12.tar.gz saved [35874671/35874671]
  17.  
  18. [root@ggg2 Desktop]# tar -zxvf MysqL-5.6.12.tar.gz
  19.  
  20. [root@ggg2 Desktop]# cd MysqL-5.6.12


四:用cmake工具配置MysqL代码

创建MysqL的安装目录,在cmake时指定参数 -DCMAKE_INSTALL_PREFIX ,就是指定MysqL程序要安装的目录:

  1. [root@ggg2 Desktop]# mkdir -p /usr/local/MysqL

不过运行中报错了:

  1. [root@ggg2 MysqL-5.6.12]# cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/MysqL \
  2. -DDEFAULT_CHARSET=utf8 \
  3. -DDEFAULT_COLLATION=utf8_general_ci \
  4. -DENABLED_LOCAL_INFILE=ON \
  5. -DWITH_INNOBASE_STORAGE_ENGINE=1 \
  6. -DWITH_FEDERATED_STORAGE_ENGINE=1 \
  7. -DWITH_BALACKHOLE_STORAGE_ENGINE=1 \
  8. -DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 \
  9. -DWITH_PARTITION_STORAGE_ENGINE=1 \
  10. -DWITH_PERFSCHEMA_STORAGE_ENGINE=1 \
  11. -DCOMPLILATION_COMMENT='ggg for MysqL' \
  12. -DWITH_READLINE=0N \
  13. -DSYSCONFDIR=/data/MysqLdata/3306 \
  14. -DMysqL_UNIX_ADDR=/data/MysqLdata/3306/MysqL.sock
  15.  
  16.  
  17. -- Could NOT find Curses (missing: CURSES_LIBRARY CURSES_INCLUDE_PATH)
  18. CMake Error at cmake/readline.cmake:85 (MESSAGE):
  19. 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.
  20. Call Stack (most recent call first):
  21. cmake/readline.cmake:128 (FIND_CURSES)
  22. cmake/readline.cmake:202 (MysqL_USE_BUNDLED_EDITLINE)
  23. CMakeLists.txt:325 (MysqL_CHECK_EDITLINE)
  24.  
  25.  
  26. -- Configuring incomplete,errors occurred!

从报错信息中可以看出,要删除 CMakeCache.txt文件,然后,对于rehat以及派生的版本,要安装 ncurses-devel:
  1. [root@ggg2 Desktop]# yum -y install ncurses-devel

再次运行cmake:

  1. [root@ggg2 MysqL-5.6.12]# cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/MysqL \
  2. -DDEFAULT_CHARSET=utf8 \
  3. -DDEFAULT_COLLATION=utf8_general_ci \
  4. -DENABLED_LOCAL_INFILE=ON \
  5. -DWITH_INNOBASE_STORAGE_ENGINE=1 \
  6. -DWITH_FEDERATED_STORAGE_ENGINE=1 \
  7. -DWITH_BALACKHOLE_STORAGE_ENGINE=1 \
  8. -DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 \
  9. -DWITH_PARTITION_STORAGE_ENGINE=1 \
  10. -DWITH_PERFSCHEMA_STORAGE_ENGINE=1 \
  11. -DCOMPLILATION_COMMENT='ggg for MysqL' \
  12. -DWITH_READLINE=0N \
  13. -DSYSCONFDIR=/data/MysqLdata/3306 \
  14. -DMysqL_UNIX_ADDR=/data/MysqLdata/3306/MysqL.sock
  15. .....................
  16. .....................
  17. -- Check size of wchar_t
  18. -- Check size of wchar_t - done
  19. -- Check size of wctype_t
  20. -- Check size of wctype_t - done
  21. -- Check size of wint_t
  22. -- Check size of wint_t - done
  23. -- Found Curses: /usr/lib64/libcurses.so
  24. -- Looking for tputs in /usr/lib64/libcurses.so
  25. -- Looking for tputs in /usr/lib64/libcurses.so - found
  26. -- Performing Test HAVE_DECL_TGOTO
  27. -- Performing Test HAVE_DECL_TGOTO - Success
  28. -- Looking for strvis
  29. -- Looking for strvis - not found
  30. -- Looking for strunvis
  31. -- Looking for strunvis - not found
  32. -- Looking for include files HAVE_LIBAIO_H
  33. -- Looking for include files HAVE_LIBAIO_H - not found.
  34. -- Looking for io_queue_init in aio
  35. -- Looking for io_queue_init in aio - not found
  36. -- Looking for sched_getcpu
  37. -- Looking for sched_getcpu - found
  38. -- Performing Test HAVE_IB_GCC_ATOMIC_BUILTINS
  39. -- Performing Test HAVE_IB_GCC_ATOMIC_BUILTINS - Success
  40. -- Performing Test HAVE_IB_GCC_ATOMIC_BUILTINS_64
  41. -- Performing Test HAVE_IB_GCC_ATOMIC_BUILTINS_64 - Success
  42. -- Performing Test HAVE_IB_ATOMIC_PTHREAD_T_GCC
  43. -- Performing Test HAVE_IB_ATOMIC_PTHREAD_T_GCC - Success
  44. -- Looking for asprintf
  45. -- Looking for asprintf - found
  46. -- Check size of pthread_t
  47. -- Check size of pthread_t - done
  48. -- Using cmake version 2.8.4
  49. -- Not building NDB
  50. -- Performing Test HAVE_PEERCRED
  51. -- Performing Test HAVE_PEERCRED - Success
  52. -- Library MysqLclient depends on OSLIBS -lpthread;m;rt;dl
  53. -- Googlemock was not found. gtest-based unit tests will be disabled. You can run cmake . -DENABLE_DOWNLOADS=1 to automatically download and build required components from source.
  54. -- If you are inside a firewall,you may need to use an http proxy: export http_proxy=http://foo.bar.com:80
  55. Warning: Bison executable not found in PATH
  56. -- Library MysqLserver depends on OSLIBS -lpthread;m;rt;crypt;dl
  57. -- Configuring done
  58. -- Generating done
  59. CMake Warning: The variable,'COMPLILATION_COMMENT',specified manually,was not used during the generation.
  60. CMake Warning: The variable,'WITH_BALACKHOLE_STORAGE_ENGINE','WITH_READLINE',was not used during the generation.
  61. -- Build files have been written to: /root/Desktop/MysqL-5.6.12

五:编译安装

整个过程大概要20分钟左右:

  1. [root@ggg2 MysqL-5.6.12]# make && make install
至此,安装完成 , 不过接下来,还要对MysqL进行配置,才能让MysqL跑起来


六:创建数据库服务

增加MysqL用户用户组。

先创建MysqL用户组,然后useradd 命令是指新创建用户MysqL,-g指定要把这个新用户加入到MysqL

  1. [root@ggg2 MysqL]# groupadd MysqL
  2.  
  3. [root@ggg2 MysqL]# useradd -g MysqL MysqL

修改/usr/local/MysqL目录的owner为 MysqL用户

  1. [root@ggg2 Desktop]# cd /usr/local/MysqL
  2. [root@ggg2 MysqL]# ls
  3. bin data include lib MysqL-test scripts sql-bench
  4. COPYING docs INSTALL-BINARY man README share
  5. support-files
  6.  
  7. [root@ggg2 MysqLdata]# chown -R MysqL:MysqL /usr/local/MysqL


修改/home/MysqL/.bash_logout 文件,在最后增加

export LANG=zh_CN.GB18030
export PATH=/usr/local/MysqL/bin:$PATH

之所以要增加这2行,是以后当MysqL用户登陆后,就可以直接执行MysqL命令行,不用在切换目录。

  1. [root@ggg2 MysqLdata]# cd /home/MysqL
  2. [root@ggg2 MysqL]# ls -al
  3. total 28
  4. drwx------. 4 MysqL MysqL 4096 Aug 21 22:47 .
  5. drwxr-xr-x. 4 root root 4096 Aug 21 22:47 ..
  6. -rw-r--r--. 1 MysqL MysqL 18 Oct 16 2014 .bash_logout
  7. -rw-r--r--. 1 MysqL MysqL 176 Oct 16 2014 .bash_profile
  8. -rw-r--r--. 1 MysqL MysqL 124 Oct 16 2014 .bashrc
  9. drwxr-xr-x. 2 MysqL MysqL 4096 Nov 12 2010 .gnome2
  10. drwxr-xr-x. 4 MysqL MysqL 4096 Aug 18 23:13 .mozilla
  11.  
  12. [root@ggg2 MysqL]# vi /home/MysqL/.bash_logout
  13. [root@ggg2 MysqL]# cat /home/MysqL/.bash_logout
  14. # ~/.bash_logout
  15.  
  16.  
  17. [root@ggg2 MysqL]# vi /home/MysqL/.bash_profile
  18. [root@ggg2 MysqL]# cat /home/MysqL/.bash_profile
  19. # .bash_profile
  20.  
  21.  
  22. # Get the aliases and functions
  23. if [ -f ~/.bashrc ]; then
  24. . ~/.bashrc
  25. fi
  26.  
  27.  
  28. # User specific environment and startup programs
  29.  
  30.  
  31. PATH=$PATH:$HOME/bin
  32.  
  33.  
  34. export PATH
  35.  
  36.  
  37. export LANG=zh_CN.GB18030
  38. export PATH=/usr/local/MysqL/bin:$PATH

创建数据文件的存储目录:
  1. [root@ggg2 Desktop]# mkdir -p /data/MysqLdata/{3306/{data,tmp,binlog},backup,scripts}
  2. [root@ggg2 Desktop]# ls -al /data/MysqLdata
  3. total 20
  4. drwxr-xr-x. 5 root root 4096 Aug 24 22:24 .
  5. drwxr-xr-x. 3 root root 4096 Aug 22 22:39 ..
  6. drwxr-xr-x. 5 root root 4096 Aug 24 22:24 3306
  7. drwxr-xr-x. 2 root root 4096 Aug 24 22:24 backup
  8. drwxr-xr-x. 2 root root 4096 Aug 24 22:24 scripts
  9. [root@ggg2 Desktop]# ls -al /data/MysqLdata/3306
  10. total 20
  11. drwxr-xr-x. 5 root root 4096 Aug 24 22:24 .
  12. drwxr-xr-x. 5 root root 4096 Aug 24 22:24 ..
  13. drwxr-xr-x. 2 root root 4096 Aug 24 22:24 binlog
  14. drwxr-xr-x. 2 root root 4096 Aug 24 22:24 data
  15. drwxr-xr-x. 2 root root 4096 Aug 24 22:24 tmp
  16. [root@ggg2 Desktop]#


改变数据目录的owner,切换到msyql用户
  1. [root@ggg2 Desktop]# chown -R MysqL:MysqL /data/MysqLdata
  2. [root@ggg2 Desktop]# su - MysqL
  3. [MysqL@ggg2 ~]$ cd /usr/local/MysqL
  4. [MysqL@ggg2 MysqL]$

创建.cnf 配置文件,实际上在/user/local/MysqL/support-files 目录下个my-default.cnf文件可以参考:
  1. [MysqL@ggg2 MysqL]$ ll support-files
  2. 总用量 36
  3. -rwxr-xr-x. 1 MysqL MysqL 1153 8 22 23:18 binary-configure
  4. -rw-r--r--. 1 MysqL MysqL 773 7 3 2013 magic
  5. -rw-r--r--. 1 MysqL MysqL 1126 8 22 23:18 my-default.cnf
  6. -rwxr-xr-x. 1 MysqL MysqL 1061 8 22 23:18 MysqLd_multi.server
  7. -rwxr-xr-x. 1 MysqL MysqL 894 8 22 23:18 MysqL-log-rotate
  8. -rwxr-xr-x. 1 MysqL MysqL 10880 8 22 23:18 MysqL.server
  9. drwxr-xr-x. 2 MysqL MysqL 4096 8 22 23:35 solaris
  10. [MysqL@ggg2 MysqL]$

创建my.cnf文件,接下来可以按需写上各个配置参数:
  1. [root@ggg2 Desktop]# touch /data/MysqLdata/3306/my.cnf

  1. # For advice on how to change settings please see
  2. # http://dev.MysqL.com/doc/refman/5.6/en/server-configuration-defaults.html
  3. # *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
  4. # *** default location during install,and will be replaced if you
  5. # *** upgrade to a newer version of MysqL.
  6.  
  7. [MysqLd]
  8.  
  9. # Remove leading # and set to the amount of RAM for the most important data
  10. # cache in MysqL. Start at 70% of total RAM for dedicated server,else 10%.
  11. # innodb_buffer_pool_size = 128M
  12.  
  13. # Remove leading # to turn on a very important data integrity option: logging
  14. # changes to the binary log between backups.
  15. # log_bin
  16.  
  17. # These are commonly set,remove the # and set as required.
  18. # basedir = .....
  19. # datadir = .....
  20. # port = .....
  21. # server_id = .....
  22. # socket = .....
  23.  
  24. # Remove leading # to set options mainly useful for reporting servers.
  25. # The server defaults are faster for transactions and fast SELECTs.
  26. # Adjust sizes as needed,experiment to find the optimal values.
  27. # join_buffer_size = 128M
  28. # sort_buffer_size = 2M
  29. # read_rnd_buffer_size = 2M
  30.  
  31. sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES


七:启动数据库服务



八:配置MysqL数据库

猜你在找的CentOS相关文章