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

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

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

先下载cmake工具的源代码

[root@ggg2 Desktop]# wget http://www.cmake.org/files/v2.8/cmake-2.8.4.tar.gz
--2016-08-21 22:09:21--  http://www.cmake.org/files/v2.8/cmake-2.8.4.tar.gz
Resolving www.cmake.org... 66.194.253.19
Connecting to www.cmake.org|66.194.253.19|:80... connected.
HTTP request sent,awaiting response... 301 Moved Permanently
Location: http://cmake.org/files/v2.8/cmake-2.8.4.tar.gz [following]
--2016-08-21 22:09:22--  http://cmake.org/files/v2.8/cmake-2.8.4.tar.gz
Resolving cmake.org... 66.194.253.19
Connecting to cmake.org|66.194.253.19|:80... connected.
HTTP request sent,awaiting response... 301 Moved Permanently
Location: https://cmake.org/files/v2.8/cmake-2.8.4.tar.gz [following]
--2016-08-21 22:09:23--  https://cmake.org/files/v2.8/cmake-2.8.4.tar.gz
Connecting to cmake.org|66.194.253.19|:443... connected.
HTTP request sent,awaiting response... 200 OK
Length: 5477628 (5.2M) [application/x-gzip]
Saving to: “cmake-2.8.4.tar.gz”

100%[=========================================================>] 5,477,628    101K/s   in 63s     

2016-08-21 22:10:27 (84.8 KB/s) - “cmake-2.8.4.tar.gz” saved [5477628/5477628]

然后切换目录,进行 配置,需要注意的是 ./configure 是源码安装的很重要的一步,对要安装的软件进行配置,检查当前的环境是否满足要安装软件的依赖关系:
[root@ggg2 Desktop]# cd cmake-2.8.4
[root@ggg2 cmake-2.8.4]# ./configure
---------------------------------------------
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: /root/Desktop/cmake-2.8.4/Bootstrap.cmk/cmake_bootstrap.log
---------------------------------------------
---------------------------------------------
CMake 2.8.4,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: /root/Desktop/cmake-2.8.4/Bootstrap.cmk/cmake_bootstrap.log
---------------------------------------------

从上面的输出,发现是报错了,仔细查看报错信息,发现是 没有找到合适的c、c++编译器,所以接下来要安装编译器:
[root@ggg2 ~]# yum -y install gcc
Loaded plugins: fastestmirror,refresh-packagekit,security
Setting up Install Process
Loading mirror speeds from cached hostfile
 * base: centos.ustc.edu.cn
 * extras: ftp.sjtu.edu.cn
 * updates: centos.ustc.edu.cn
Resolving Dependencies
--> Running transaction check
---> Package gcc.x86_64 0:4.4.7-17.el6 will be installed
--> Processing Dependency: libgomp = 4.4.7-17.el6 for package: gcc-4.4.7-17.el6.x86_64
--> Processing Dependency: cpp = 4.4.7-17.el6 for package: gcc-4.4.7-17.el6.x86_64
--> Processing Dependency: libgcc >= 4.4.7-17.el6 for package: gcc-4.4.7-17.el6.x86_64
--> Processing Dependency: cloog-ppl >= 0.15 for package: gcc-4.4.7-17.el6.x86_64
--> Running transaction check
---> Package cloog-ppl.x86_64 0:0.15.7-1.2.el6 will be installed
--> Processing Dependency: libppl_c.so.2()(64bit) for package: cloog-ppl-0.15.7-1.2.el6.x86_64
--> Processing Dependency: libppl.so.7()(64bit) for package: cloog-ppl-0.15.7-1.2.el6.x86_64
---> Package cpp.x86_64 0:4.4.7-17.el6 will be installed
--> Processing Dependency: libmpfr.so.1()(64bit) for package: cpp-4.4.7-17.el6.x86_64
---> Package libgcc.x86_64 0:4.4.7-11.el6 will be updated
---> Package libgcc.x86_64 0:4.4.7-17.el6 will be an update
---> Package libgomp.x86_64 0:4.4.7-11.el6 will be updated
---> Package libgomp.x86_64 0:4.4.7-17.el6 will be an update
--> Running transaction check
---> Package mpfr.x86_64 0:2.4.1-6.el6 will be installed
---> Package ppl.x86_64 0:0.10.2-11.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package            Arch            Version                 Repository     Size
================================================================================
Installing:
 gcc                x86_64          4.4.7-17.el6            base           10 M
Installing for dependencies:
 cloog-ppl          x86_64          0.15.7-1.2.el6          base           93 k
 cpp                x86_64          4.4.7-17.el6            base          3.7 M
 mpfr               x86_64          2.4.1-6.el6             base          157 k
 ppl                x86_64          0.10.2-11.el6           base          1.3 M
Updating for dependencies:
 libgcc             x86_64          4.4.7-17.el6            base          103 k
 libgomp            x86_64          4.4.7-17.el6            base          134 k

Transaction Summary
================================================================================
Install       5 Package(s)
Upgrade       2 Package(s)

Total size: 16 M
Downloading Packages:
warning: rpmts_HdrFromFdno: Header V3 RSA/SHA1 Signature,key ID c105b9de: NOKEY
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
Importing GPG key 0xC105B9DE:
 Userid : CentOS-6 Key (CentOS 6 Official Signing Key) <centos-6-key@centos.org>
 Package: centos-release-6-6.el6.centos.12.2.x86_64 (@anaconda-CentOS-201410241409.x86_64/6.6)
 From   : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Updating   : libgcc-4.4.7-17.el6.x86_64                                   1/9 
  Installing : ppl-0.10.2-11.el6.x86_64                                     2/9 
  Installing : cloog-ppl-0.15.7-1.2.el6.x86_64                              3/9 
  Updating   : libgomp-4.4.7-17.el6.x86_64                                  4/9 
  Installing : mpfr-2.4.1-6.el6.x86_64                                      5/9 
  Installing : cpp-4.4.7-17.el6.x86_64                                      6/9 
  Installing : gcc-4.4.7-17.el6.x86_64                                      7/9 
  Cleanup    : libgomp-4.4.7-11.el6.x86_64                                  8/9 
  Cleanup    : libgcc-4.4.7-11.el6.x86_64                                   9/9 
  Verifying  : libgcc-4.4.7-17.el6.x86_64                                   1/9 
  Verifying  : ppl-0.10.2-11.el6.x86_64                                     2/9 
  Verifying  : gcc-4.4.7-17.el6.x86_64                                      3/9 
  Verifying  : mpfr-2.4.1-6.el6.x86_64                                      4/9 
  Verifying  : libgomp-4.4.7-17.el6.x86_64                                  5/9 
  Verifying  : cpp-4.4.7-17.el6.x86_64                                      6/9 
  Verifying  : cloog-ppl-0.15.7-1.2.el6.x86_64                              7/9 
  Verifying  : libgcc-4.4.7-11.el6.x86_64                                   8/9 
  Verifying  : libgomp-4.4.7-11.el6.x86_64                                  9/9 

Installed:
  gcc.x86_64 0:4.4.7-17.el6                                                     

Dependency Installed:
  cloog-ppl.x86_64 0:0.15.7-1.2.el6          cpp.x86_64 0:4.4.7-17.el6          
  mpfr.x86_64 0:2.4.1-6.el6                  ppl.x86_64 0:0.10.2-11.el6         

Dependency Updated:
  libgcc.x86_64 0:4.4.7-17.el6           libgomp.x86_64 0:4.4.7-17.el6          

Complete!
[root@ggg2 cmake-2.8.4]# yum -y install gcc-c++
Loaded plugins: fastestmirror,security
Setting up Install Process
Loading mirror speeds from cached hostfile
 * base: centos.ustc.edu.cn
 * extras: ftp.sjtu.edu.cn
 * updates: centos.ustc.edu.cn
Resolving Dependencies
--> Running transaction check
---> Package gcc-c++.x86_64 0:4.4.7-17.el6 will be installed
--> Processing Dependency: libstdc++-devel = 4.4.7-17.el6 for package: gcc-c++-4.4.7-17.el6.x86_64
--> Processing Dependency: libstdc++ = 4.4.7-17.el6 for package: gcc-c++-4.4.7-17.el6.x86_64
--> Running transaction check
---> Package libstdc++.x86_64 0:4.4.7-11.el6 will be updated
---> Package libstdc++.x86_64 0:4.4.7-17.el6 will be an update
---> Package libstdc++-devel.x86_64 0:4.4.7-17.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===================================================================================================
 Package                     Arch               Version                     Repository        Size
===================================================================================================
Installing:
 gcc-c++                     x86_64             4.4.7-17.el6                base             4.7 M
Installing for dependencies:
 libstdc++-devel             x86_64             4.4.7-17.el6                base             1.6 M
Updating for dependencies:
 libstdc++                   x86_64             4.4.7-17.el6                base             295 k

Transaction Summary
===================================================================================================
Install       2 Package(s)
Upgrade       1 Package(s)

Total download size: 6.6 M
Downloading Packages:
(1/3): gcc-c++-4.4.7-17.el6.x86_64.rpm                                      | 4.7 MB     00:21     
(2/3): libstdc++-4.4.7-17.el6.x86_64.rpm                                    | 295 kB     00:00     
(3/3): libstdc++-devel-4.4.7-17.el6.x86_64.rpm                              | 1.6 MB     00:11     
---------------------------------------------------------------------------------------------------
Total                                                              195 kB/s | 6.6 MB     00:34     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Updating   : libstdc++-4.4.7-17.el6.x86_64                                                   1/4 
  Installing : libstdc++-devel-4.4.7-17.el6.x86_64                                             2/4 
  Installing : gcc-c++-4.4.7-17.el6.x86_64                                                     3/4 
  Cleanup    : libstdc++-4.4.7-11.el6.x86_64                                                   4/4 
  Verifying  : gcc-c++-4.4.7-17.el6.x86_64                                                     1/4 
  Verifying  : libstdc++-4.4.7-17.el6.x86_64                                                   2/4 
  Verifying  : libstdc++-devel-4.4.7-17.el6.x86_64                                             3/4 
  Verifying  : libstdc++-4.4.7-11.el6.x86_64                                                   4/4 

Installed:
  gcc-c++.x86_64 0:4.4.7-17.el6                                                                    

Dependency Installed:
  libstdc++-devel.x86_64 0:4.4.7-17.el6                                                            

Dependency Updated:
  libstdc++.x86_64 0:4.4.7-17.el6                                                                  

Complete!

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

然后,再次尝试配置,且进行编译、安装:
[root@ggg2 cmake-2.8.4]# ./configure
此处省略1w行

[root@ggg2 cmake-2.8.4]# gmake && make install
此处省略1k行
至此,cmake工具安装完成, 不容易啊


二、修改MysqL用户的限制

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

MysqL		 soft    nproc           2047
MysqL            hard    nproc           16384
MysqL            soft    nofile          1024
MysqL            hard    nofile          65536
[root@ggg2 Desktop]# cat /etc/security/limits.conf
# /etc/security/limits.conf
#
#Each line describes a limit for a user in the form:
#
#<domain>        <type>  <item>  <value>
#
#Where:
#<domain> can be:
#        - a user name
#        - a group name,with @group Syntax
#        - the wildcard *,for default entry
#        - the wildcard %,can be also used with %group Syntax,#                 for maxlogin limit
#
#<type> can have the two values:
#        - "soft" for enforcing the soft limits
#        - "hard" for enforcing hard limits
#
#<item> can be one of the following:
#        - core - limits the core file size (KB)
#        - data - max data size (KB)
#        - fsize - maximum filesize (KB)
#        - memlock - max locked-in-memory address space (KB)
#        - nofile - max number of open file descriptors
#        - RSS - max resident set size (KB)
#        - stack - max stack size (KB)
#        - cpu - max cpu time (MIN)
#        - nproc - max number of processes
#        - as - address space limit (KB)
#        - maxlogins - max number of logins for this user
#        - maxsyslogins - max number of logins on the system
#        - priority - the priority to run user process with
#        - locks - max number of file locks the user can hold
#        - sigpending - max number of pending signals
#        - msgqueue - max memory used by POSIX message queues (bytes)
#        - nice - max nice priority allowed to raise to values: [-20,19]
#        - rtprio - max realtime priority
#
#<domain>      <type>  <item>         <value>
#

#*               soft    core            0
#*               hard    RSS             10000
#@student        hard    nproc           20
#@faculty        soft    nproc           20
#@faculty        hard    nproc           50
#ftp             hard    nproc           0
#@student        -       maxlogins       4

MysqL		 soft    nproc           2047
MysqL            hard    nproc           16384
MysqL            soft    nofile          1024
MysqL            hard    nofile          65536

# End of file

三、下载MysqL代码,解压
[root@ggg2 Desktop]# wget http://dev.MysqL.com/get/Downloads/MysqL-5.6/MysqL-5.6.12.tar.gz
--2016-08-21 23:01:28--  http://dev.MysqL.com/get/Downloads/MysqL-5.6/MysqL-5.6.12.tar.gz
Resolving dev.MysqL.com... 137.254.60.11
Connecting to dev.MysqL.com|137.254.60.11|:80... connected.
HTTP request sent,awaiting response... 302 Found
Location: http://cdn.MysqL.com//archives/MysqL-5.6/MysqL-5.6.12.tar.gz [following]
--2016-08-21 23:01:29--  http://cdn.MysqL.com//archives/MysqL-5.6/MysqL-5.6.12.tar.gz
Resolving cdn.MysqL.com... 23.77.240.248
Connecting to cdn.MysqL.com|23.77.240.248|:80... connected.
HTTP request sent,awaiting response... 200 OK
Length: 35874671 (34M) [application/x-tar-gz]
Saving to: “MysqL-5.6.12.tar.gz”

100%[=========================================================>] 35,874,671   504K/s   in 72s     

2016-08-21 23:02:41 (487 KB/s) - “MysqL-5.6.12.tar.gz” saved [35874671/35874671]

[root@ggg2 Desktop]# tar -zxvf MysqL-5.6.12.tar.gz 

[root@ggg2 Desktop]# cd MysqL-5.6.12


四:用cmake工具配置MysqL代码

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

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

不过运行中报错了:

[root@ggg2 MysqL-5.6.12]# cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/MysqL \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DENABLED_LOCAL_INFILE=ON \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
-DWITH_BALACKHOLE_STORAGE_ENGINE=1 \
-DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DWITH_PERFSCHEMA_STORAGE_ENGINE=1 \
-DCOMPLILATION_COMMENT='ggg for MysqL' \
-DWITH_READLINE=0N \
-DSYSCONFDIR=/data/MysqLdata/3306 \
-DMysqL_UNIX_ADDR=/data/MysqLdata/3306/MysqL.sock


-- Could NOT find Curses (missing:  CURSES_LIBRARY CURSES_INCLUDE_PATH) 
CMake Error at cmake/readline.cmake:85 (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:128 (FIND_CURSES)
  cmake/readline.cmake:202 (MysqL_USE_BUNDLED_EDITLINE)
  CMakeLists.txt:325 (MysqL_CHECK_EDITLINE)


-- Configuring incomplete,errors occurred!

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

再次运行cmake:

[root@ggg2 MysqL-5.6.12]# cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/MysqL \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DENABLED_LOCAL_INFILE=ON \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
-DWITH_BALACKHOLE_STORAGE_ENGINE=1 \
-DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DWITH_PERFSCHEMA_STORAGE_ENGINE=1 \
-DCOMPLILATION_COMMENT='ggg for MysqL' \
-DWITH_READLINE=0N \
-DSYSCONFDIR=/data/MysqLdata/3306 \
-DMysqL_UNIX_ADDR=/data/MysqLdata/3306/MysqL.sock
.....................
.....................
-- Check size of wchar_t
-- Check size of wchar_t - done
-- Check size of wctype_t
-- Check size of wctype_t - done
-- Check size of wint_t
-- Check size of wint_t - done
-- Found Curses: /usr/lib64/libcurses.so 
-- Looking for tputs in /usr/lib64/libcurses.so
-- Looking for tputs in /usr/lib64/libcurses.so - found
-- Performing Test HAVE_DECL_TGOTO
-- Performing Test HAVE_DECL_TGOTO - Success
-- Looking for strvis
-- Looking for strvis - not found
-- Looking for strunvis
-- Looking for strunvis - not found
-- Looking for include files HAVE_LIBAIO_H
-- Looking for include files HAVE_LIBAIO_H - not found.
-- Looking for io_queue_init in aio
-- Looking for io_queue_init in aio - not found
-- Looking for sched_getcpu
-- Looking for sched_getcpu - found
-- Performing Test HAVE_IB_GCC_ATOMIC_BUILTINS
-- Performing Test HAVE_IB_GCC_ATOMIC_BUILTINS - Success
-- Performing Test HAVE_IB_GCC_ATOMIC_BUILTINS_64
-- Performing Test HAVE_IB_GCC_ATOMIC_BUILTINS_64 - Success
-- Performing Test HAVE_IB_ATOMIC_PTHREAD_T_GCC
-- Performing Test HAVE_IB_ATOMIC_PTHREAD_T_GCC - Success
-- Looking for asprintf
-- Looking for asprintf - found
-- Check size of pthread_t
-- Check size of pthread_t - done
-- Using cmake version 2.8.4
-- Not building NDB
-- Performing Test HAVE_PEERCRED
-- Performing Test HAVE_PEERCRED - Success
-- Library MysqLclient depends on OSLIBS -lpthread;m;rt;dl
-- 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.
-- If you are inside a firewall,you may need to use an http proxy: export http_proxy=http://foo.bar.com:80
Warning: Bison executable not found in PATH
-- Library MysqLserver depends on OSLIBS -lpthread;m;rt;crypt;dl
-- Configuring done
-- Generating done
CMake Warning: The variable,'COMPLILATION_COMMENT',specified manually,was not used during the generation.
CMake Warning: The variable,'WITH_BALACKHOLE_STORAGE_ENGINE','WITH_READLINE',was not used during the generation.
-- Build files have been written to: /root/Desktop/MysqL-5.6.12

五:编译安装

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

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


六:创建数据库服务

增加MysqL用户用户组。

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

[root@ggg2 MysqL]# groupadd MysqL

[root@ggg2 MysqL]# useradd -g MysqL MysqL

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

[root@ggg2 Desktop]# cd /usr/local/MysqL
[root@ggg2 MysqL]# ls
bin      data  include         lib  MysqL-test  scripts  sql-bench
COPYING  docs  INSTALL-BINARY  man  README      share    
support-files

[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命令行,不用在切换目录。

[root@ggg2 MysqLdata]# cd /home/MysqL
[root@ggg2 MysqL]# ls -al
total 28
drwx------. 4 MysqL MysqL 4096 Aug 21 22:47 .
drwxr-xr-x. 4 root  root  4096 Aug 21 22:47 ..
-rw-r--r--. 1 MysqL MysqL   18 Oct 16  2014 .bash_logout
-rw-r--r--. 1 MysqL MysqL  176 Oct 16  2014 .bash_profile
-rw-r--r--. 1 MysqL MysqL  124 Oct 16  2014 .bashrc
drwxr-xr-x. 2 MysqL MysqL 4096 Nov 12  2010 .gnome2
drwxr-xr-x. 4 MysqL MysqL 4096 Aug 18 23:13 .mozilla

[root@ggg2 MysqL]# vi /home/MysqL/.bash_logout
[root@ggg2 MysqL]# cat /home/MysqL/.bash_logout
# ~/.bash_logout


[root@ggg2 MysqL]# vi /home/MysqL/.bash_profile
[root@ggg2 MysqL]# cat /home/MysqL/.bash_profile
# .bash_profile


# Get the aliases and functions
if [ -f ~/.bashrc ]; then
	. ~/.bashrc
fi


# User specific environment and startup programs


PATH=$PATH:$HOME/bin


export PATH


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

创建数据文件的存储目录:
[root@ggg2 Desktop]# mkdir -p /data/MysqLdata/{3306/{data,tmp,binlog},backup,scripts}
[root@ggg2 Desktop]# ls -al /data/MysqLdata
total 20
drwxr-xr-x. 5 root root 4096 Aug 24 22:24 .
drwxr-xr-x. 3 root root 4096 Aug 22 22:39 ..
drwxr-xr-x. 5 root root 4096 Aug 24 22:24 3306
drwxr-xr-x. 2 root root 4096 Aug 24 22:24 backup
drwxr-xr-x. 2 root root 4096 Aug 24 22:24 scripts
[root@ggg2 Desktop]# ls -al /data/MysqLdata/3306
total 20
drwxr-xr-x. 5 root root 4096 Aug 24 22:24 .
drwxr-xr-x. 5 root root 4096 Aug 24 22:24 ..
drwxr-xr-x. 2 root root 4096 Aug 24 22:24 binlog
drwxr-xr-x. 2 root root 4096 Aug 24 22:24 data
drwxr-xr-x. 2 root root 4096 Aug 24 22:24 tmp
[root@ggg2 Desktop]# 


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

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

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

# For advice on how to change settings please see
# http://dev.MysqL.com/doc/refman/5.6/en/server-configuration-defaults.html
# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
# *** default location during install,and will be replaced if you
# *** upgrade to a newer version of MysqL.

[MysqLd]

# Remove leading # and set to the amount of RAM for the most important data
# cache in MysqL. Start at 70% of total RAM for dedicated server,else 10%.
# innodb_buffer_pool_size = 128M

# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin

# These are commonly set,remove the # and set as required.
# basedir = .....
# datadir = .....
# port = .....
# server_id = .....
# socket = .....

# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed,experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M 

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES 


七:启动数据库服务



八:配置MysqL数据库

原文链接:https://www.f2er.com/centos/381051.html

猜你在找的CentOS相关文章