Linux下MySQL源码编译安装(eg:mysql-5.6.27.tar.gz )

转自:http://blog.csdn.net/typa01_kk/article/details/49466113

Linux下MySQL源码安装(eg:mysql-5.6.27.tar.gz ):

1:准备MySQL源码安装包:

mysql-5.6.27.tar.gz、cmake-3.3.2.tar.gz、ncurses-6.0.tar.gz

注:centos请安装:

yum install -y ncurses-devel

yum install -y perl-Module-Install.noarch

网址:

https://cmake.org/download/

ftp://invisible-island.net/ncurses/

http://ftp.kaist.ac.kr/mysql/Downloads/

环境:

mysql-5.6.27.tar.gz   

CentOS release 6.5 (Final)

注:MySQL源码安装:从mysql5.5以后是通过cmake来编译的安装的,但cmake要依赖ncurses,所以你懂的,有需要依赖就装给它!

注:所有错误和说明解释、ncurses安装,在备注附近,文章最下方有解决方案!

2:若未安装,安装cmake:

[plain]  view plain copy
  1. [root@tsxs installfiles]# tar zxvf cmake-3.3.2.tar.gz   
  2. [root@tsxs installfiles]# cd cmake-3.3.2  
  3. [root@tsxs cmake-3.3.2]# ls  
  4. Auxiliary  CMakeCPack.cmake CMakeGraphVizOptions.cmake  CMakeLogo.gif   
  5. CompileFlags.cmake  CONTRIBUTING.rst  CTestConfig.cmake DartConfig.cmake  Help   
  6. Modules  Source Tests bootstrap  CMakeCPackOptions.cmake.in  CMakeLists.txt  
  7. cmake_uninstall.cmake.in  configure Copyright.txt CTestCustom.cmake.in doxygen.config  
  8. Licenses  README.rst  Templates  Utilities  
  9. [root@tsxs cmake-3.3.2]# ./bootstrap   
  10. [root@tsxs cmake-3.3.2]# make   
  11. [root@tsxs cmake-3.3.2]# make install  

测试:输入有关cmake的使用命令: 

注:CMake是一个跨平台的安装(编译)工具,可以用简单的语句来描述所有平台的安装(编译过程)。 可以一次:make && make install

[plain]  view plain copy
  1. [root@tsxs installfiles]# cmake --version  
  2. [root@tsxs installfiles]# cmake --help  
3:安装MySQL数据库:

MySQL数据库添加用户和组:

[plain]  view plain copy
  1. 查看是否存在MySQL组:  
  2. [root@tsxs home]# grep mysql /etc/group  
  3. 不存在创建MySQL组:  
  4. [root@tsxs home]# groupadd mysql  
  5. 查看是否存在MySQL用户:  
  6. [root@tsxs home]# grep mysql /etc/passwd  
  7. 不存在创建MySQL用户:  
  8. [root@tsxs ~]# useradd mysql -g mysql -M -s /sbin/nologin   
  9. 检查:  
  10. [root@tsxs sbin]# grep mysql /etc/passwd  
  11. mysql:x:500:500::/home/mysql:/sbin/nologin  
  12. 使用groups查看用户mysql所在的组  
  13. [root@tsxs sbin]# groups mysql  
  14. mysql : mysql  

注:-g:指定新用户所属的用户组(group); -M:不建立根目录;-s:定义其使用的shell,/sbin/nologin代表用户不能登录系统。

注:也可以:

[plain]  view plain copy
  1. [root@Master home]# useradd mysql -g mysql -d /usr/local/mysql -s /bin/sh  
如果有,请修改:

[plain]  view plain copy
  1. [root@tsxs bin]# usermod -s /bin/sh -d /usr/local/mysql -g mysql mysql  

 -d:用户的登录主目录/usr/local/mysql,-s用户的登录Shell是/bin/sh

可查看:[root@tsxs bin]# vim /etc/passwd

mysql:x:500:500::/usr/local/mysql:/bin/sh

解压:

[plain]  view plain copy
  1. [root@tsxs installfiles]# tar zxvf mysql-5.6.27.tar.gz    
  2. [root@tsxs installfiles]# cd mysql-5.6.27  
  3. [root@tsxs mysql-5.6.27]# ls  
  4. BUILD  cmake  config.h.cmake  dbug extra             
  5. INSTALL-WIN-SOURCE  libmysqld mysql-test  packaging  regex  
  6. sql-bench strings  unittest win BUILD-CMAKE    
  7. CMakeLists.txt  configure.cmake  Docs include libevent  
  8. libservices  mysys  plugin scripts  sql-common  support-files   
  9. VERSION zlib client cmd-line-utils COPYING Doxyfile-perfschema  
  10. INSTALL-SOURCE libmysql man mysys_ssl README sql storage tests vio  

准备安装目录:

安装MySQL目录:/usr/local/mysql 

[plain]  view plain copy
  1. [root@tsxs local]# mkdir -p /usr/local/mysql  
MySQL数据库目录:/data

[plain]  view plain copy
  1. [root@tsxs /]# mkdir /data    

注:-p参数:如果一个目录的父目录不存在,就创建它

编译源代码:

[root@tsxs mysql-5.6.27]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql

[plain]  view plain copy
  1. cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_bin -DEXTRA_CHARSETS=all -DENABLED_LOCAL_INFILE=1  
注:MySQL安装目录
[plain]  view plain copy
  1. -DCMAKE_INSTALL_PREFIX=/usr/local/mysql     
  2. MySQL数据库存放目录       
  3. -DINSTALL_DATADIR=/data    
  4. 使用utf8字符         
  5. -DDEFAULT_CHARSET=utf8        
  6. 校验字符                    
  7. -DDEFAULT_COLLATION=utf8_bin       
  8. 安装所有扩展字符集         
  9. -DEXTRA_CHARSETS=all        
  10. 允许从本地导入数据                        
  11. -DENABLED_LOCAL_INFILE=1    
注:-D 标志这种特性为大多数编译器所支持,是传递给编译器的主要参数,绝对路径
编译源代码:

[plain]  view plain copy
  1. [root@tsxs mysql-5.6.27]# make  
安装:
[plain]  view plain copy
  1. [root@tsxs mysql-5.6.27]# make install  

也可一次:make && make install

注:

[plain]  view plain copy
  1. [root@Master /]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_bin -DEXTRA_CHARSETS=all -DENABLED_LOCAL_INFILE=1  
  2. [root@Master /]# make && make install  
  3. [root@Master mysql]# ./scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/data --user=mysql  

注:初始化日志,为下,则初始化成功:附件日志1!

安装完毕,查看安装目录 eg:/usr/local/mysql :

[plain]  view plain copy
  1. [root@tsxs mysql]# ls  
  2. bin  COPYING  data  docs  include  INSTALL-BINARY  lib  man  mysql-test  README  scripts  share  sql-bench  support-files  
初始化MySQL数据库(在安装目录下)
[plain]  view plain copy
  1. [root@tsxs mysql]# ./scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/data --user=mysql  
设置,配置文件,copy(在安装目录下):

[plain]  view plain copy
  1. [root@tsxs support-files]# cp -R my-default.cnf /etc/my.cnf  

设置启动服务(在安装目录下)

[plain]  view plain copy
  1. [root@Master support-files]# cp -R mysql.server /etc/rc.d/init.d/mysqld  

更改权限 (涉及到MySQL数据库的文件和目录都属于mysql用户):

注:不仅减少了root用户的登录和管理时间,同样也提高了安全性。注:chown在授权目录下,执行:

[plain]  view plain copy
  1. [root@tsxs /]# chown -R mysql.mysql /data  
  2. [root@Master mysql]# pwd  
  3. /usr/local/mysql  
  4. [root@Master mysql]# chown -R mysql.mysql /usr/local/mysql/  
  5. [root@tsxs etc]# chown -R mysql.mysql /etc/my.cnf  
  6. [root@tsxs init.d]# chown -R mysql.mysql mysqld   
启动MySQL服务:

[plain]  view plain copy
  1. [root@tsxs bin]# ./mysqld_safe --user=mysql &  
或者:

[plain]  view plain copy
  1. [root@tsxs bin]# service mysqld start  
  2. Starting MySQL SUCCESS!   
  3. [root@tsxs bin]# service mysqld restart  
  4. Shutting down MySQL. SUCCESS!   
  5. Starting MySQL. SUCCESS!   
  6. [root@tsxs bin]# service mysqld stop  
  7. Shutting down MySQL. SUCCESS!   
如果使用MySQL的一些命令需要配 置,将这些命令加入到系统环境变量,让他生效::

MySQL的命令目录:

[plain]  view plain copy
  1. [root@tsxs ~]# cd /usr/local/mysql/bin/  

[plain]  view plain copy
  1. [root@tsxs init.d]# vim /etc/profile  
[plain]  view plain copy
  1. #MySQL  
  2. export MYSQL_HOME=/usr/local/mysql  
  3. export PATH=$MYSQL_HOME/bin:$PATH  
[plain]  view plain copy
  1. [root@tsxs init.d]# source /etc/profile  
启动MySQL客户端client,并修改配置文件:

在下边MySQL配置文件加入客户端,登陆信息:

[plain]  view plain copy
  1. [root@tsxs bin]# vim /etc/my.cnf  
[plain]  view plain copy
  1. # The following options will be passed to all MySQL clients  
  2. [client]  
  3. #password       = your_password  
  4. port            = 3306  
  5. socket          = /data/mysql.sock  

[plain]  view plain copy
  1. # The MySQL server  
  2. [mysqld]  
  3. basedir = /usr/local/mysql  
  4. datadir = /data  
  5. port = 3306  
  6. socket = /data/mysql.sock  
  7. log-error = /data/mysql-error.log  
  8. pid-file = /data/mysql.pid  
  9. user = mysql  
启动MySQL客户端 ,第一次未设置密码:

[plain]  view plain copy
  1. [root@tsxs tmp]# mysql  
  2. Welcome to the MySQL monitor.  Commands end with ; or \g.  
  3. Your MySQL connection id is 1  
  4. Server version: 5.6.27 Source distribution  
  5.   
  6. Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.  
  7.   
  8. Oracle is a registered trademark of Oracle Corporation and/or its  
  9. affiliates. Other names may be trademarks of their respective  
  10. owners.  
  11.   
  12. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.  
  13.   
  14. mysql> quit  
  15. Bye  

设置mysql为开机启动:

[plain]  view plain copy
  1. [root@Master init.d]# chkconfig --add mysqld   
  2. [root@Master init.d]# chkconfig mysqld on  
  3. [root@Master init.d]# chkconfig --list | grep mysql  
  4. mysqld          0:off   1:off   2:on    3:on    4:on    5:on    6:off  

备注附件:

源码重新编译:MySQL等源码重新编译,在重新编译时,需要清除旧的对象文件和缓存信息。

[plain]  view plain copy
  1. # make clean  
  2. # rm -f CMakeCache.txt  
以及安装软件涉及到其他文件,eg:
# rm -rf /etc/my.cnf
安装ncurses:

注:Ncurses 提供字符终端处理库,包括面板和菜单。

解压:

[plain]  view plain copy
  1. [root@tsxs installfiles]# tar zxvf ncurses-6.0.tar.gz   
  2. [root@tsxs installfiles]# cd ncurses-6.0  
  3. [root@tsxs ncurses-6.0]# ls  
  4. aclocal.m4  announce.html.in  config.guess  configure.in          dist.mk  include       
  5. Makefile.in   MANIFEST  mk-0th.awk  mk-hdr.awk  package  README        test  
  6. Ada95       AUTHORS           config.sub    convert_configure.pl  doc      INSTALL       
  7. Makefile.os2  menu      mk-1st.awk  ncurses     panel    README.emx    TO-DO  
  8. ANNOUNCE    c++               configure     COPYING               form     install-sh    
  9. man           misc      mk-2nd.awk  NEWS        progs    README.MinGW  VERSION  
按照你的系统环境制作安装配置文件:

[plain]  view plain copy
  1. [root@tsxs ncurses-6.0]# ./configure   
编译源代码并且编译NCURSES库:

[plain]  view plain copy
  1. [root@tsxs ncurses-6.0]# make  
安装编译好的NCURSES库:

[plain]  view plain copy
  1. [root@tsxs ncurses-6.0]# make install  
检测:

[plain]  view plain copy
  1. [root@tsxs bin]# man ncurses  
或在目录:

/usr/lib下查找是否有libncurses.so或libncurses.a这个库

问题回答:

问题1:

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

解决1:

安装:ncurses,即可!

问题2:

[root@tsxs init.d]# service mysqld start
Starting MySQL. ERROR! The server quit without updating PID file (/data/mysql.pid).
[root@tsxs init.d]# service mysqld status
 ERROR! MySQL is not running, but lock file (/var/lock/subsys/mysql) exists

注(警告):问题2,如果权限和配置都觉得没有问题,请先reboot下电脑,再解决~~~!

解决2:

以上安装中,把安装MySQL的目录分配权限给mysql用户,并且在MySQL的全新配置文件加入client的配置:

[plain]  view plain copy
  1. [root@tsxs bin]# vim /etc/my.cnf  
  2. # The following options will be passed to all MySQL clients  
  3. [client]  
  4. #password       = your_password  
  5. port            = 3306  
  6. socket          = /data/mysql.sock  
  7. # The MySQL server  
  8. [mysqld]  
  9. basedir = /usr/local/mysql  
  10. datadir = /data  
  11. port = 3306  
  12. socket = /data/mysql.sock  
  13. log-error = /data/mysql-error.log  
  14. pid-file = /data/mysql.pid  
  15. user = mysql  
[plain]  view plain copy
  1. [root@tsxs local]# chown -R mysql.mysql /usr/local/mysql/  
  2. [root@tsxs /]# chown -R mysql.mysql /data  
  3. [root@tsxs etc]# chown -R mysql.mysql /etc/my.cnf  
  4. [root@tsxs init.d]# chown -R mysql.mysql mysqld   

注:若不能解决请关注:

1:查看:vim /etc/passwd --->  mysql:x:500:500::/usr/local/mysql:/bin/sh  --->   下mysql用户的权限和路径

2:是否安装,ncurses-devel和perl-Module-Install.noarch

3:此原因是因为,/data/mysql.pid文件的创建者为root,所以:关注1很重要!文章尾备注日志2!

4:查看,安装路径/etc/local/mysql和/data和/etc/my.cnf和启动脚本的拥有者和权限(chown/chomd)

5:花了好多时间解决问题3,甚至查启动日志,好久,最后发现,重启一下,reboot就好了!

备注图片1,2:最后!

问题3:

Error3:
[root@tsxs init.d]# mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

解决3:

问题2的MySQL配置文件client的那个配置加入即可,指定mysql.sock位置!

错误4:

[root@Master cmake-3.3.2]# ./bootstrap 
---------------------------------------------
CMake 3.3.2, Copyright 2000-2015 Kitware, 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: /home/installfiles/resourceinstall-mysql/cmake-3.3.2/Bootstrap.cmk/cmake_bootstrap.log
---------------------------------------------

解决4:

[plain]  view plain copy
  1. [root@Master cmake-3.3.2]# yum -y install gcc-c++  

问题5:

[root@Master mysql]# ./scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/data --user=mysql
FATAL ERROR: please install the following Perl modules before executing ./scripts/mysql_install_db:
Data::Dumper

解决5(centos最小安装):

[plain]  view plain copy
  1. [root@Master scripts]# yum install -y perl-Module-Install.noarch  

问题6:

[root@Master init.d]# service mysqld start
2015-11-08 00:57:58 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2015-11-08 00:57:58 0 [Note] /etc/init.d/mysqld (mysqld 5.6.27) starting as process 14599 ...
mysql启动报错:Segmentation fault

解决6:

[plain]  view plain copy
  1. [root@Master data]# yum install -y ncurses-devel  
注:然后删除:/data和/usr/local/mysql/两个目录,重新解压编译安装!别嫌麻烦!

或:

[plain]  view plain copy
  1. [root@Master ~]# vim /etc/my.cnf  
加入(此法并未解决):

[plain]  view plain copy
  1. [mysqld]  
  2. explicit_defaults_for_timestamp=true  

注:

[plain]  view plain copy
  1. 这是数据库升级过程中,timestamp在5.6以前的数据库中默认not null,如果没有显示声明timestamp的默认值,那么该列用全0的"0000-00-00 00:00:00"作为默认值  
  2. 在5.6中后,时间值是不能为全0格式,添加explicit_defaults_for_timestamp 参数  
  3. 添加之后,timestamp列可以设置默认为空,并且不填充0,如果填充了0,如果SQL_MODE为strict sql则会报错除非显示指定default current_time和on update current_time  
  4. 加入explicit_defaults_for_timestamp=true后,创建表timestamp类型Default值已经默认null了  

其他文件说明:

[plain]  view plain copy
  1. 1:cmake安装选项  
  2. CMAKE_INSTALL_PREFIX值是安装的基本目录,其他cmake选项值是不包括前缀,是相对路径名,绝对路径包括 CMAKE_INSTALL_PREFIX:MySQL的安装目录。如-DINSTALL_SBINDIR=sbin的绝对路径是 /sbin  
  3. 注:-D 标志这种特性为大多数编译器所支持,是传递给编译器的主要参数,绝对路径  
  4. 2:MySQL存储引擎选项  
  5. mysql存储引擎是插件式的,因此插件控制选项可以指定那个存储引擎安装。  
  6. configure编译插件选项--with-plugins=csv,myisam,myisammrg,heap,innobase,  
  7. archive,blackhole在cmake中没有直接对应的相同选项。对于csv,myisam,myisammrg,heap在cmake中是不需要明确指定存储引擎的名称,因为它们是强制性安装。  
  8. 3:可以使用以下选择来安装innodb,archive,blackhole存储引擎  
  9. -DWITH_INNOBASE_STORAGE_ENGINE=1  
  10. -DWITH_ARCHIVE_STORAGE_ENGINE=1  
  11. -DWITH_BLACKHOLE_STORAGE_ENGINE=1  
  12. 注:1也可以使用on代替  
  13. 如果既不是-DWITH_<ENGINE>_STORAGE_ENGINE 也不是 -DWITHOUT_<ENGINE>_STORAGE_ENGINE 来指定存储引擎,该存储引擎将安装成共享模块式的。如果不是共享模块式的将排除在外。共享模块安装时必须使用INSTALL PLUGIN语句或--plugin-load才可以使用。  
  14. 4:其他选项  
  15. 之前MySQL的编译选项大多数都支持。新旧版本之间的安装选项映射成大写字母,删除选项前面破折号,中间字符间的破折号替换成下划线。如:  
  16. --with-debug => WITH_DEBUG=1  
  17. --with-embedded-server => WITH_EMBEDDED_SERVER  
  18. 5:调试配置过程  
  19. 使用configure编译完将生成config.log和config.status文件。  
  20. 使用cmake编译完在CMakeFiles目录下生成CMakeError.log 和CMakeOutput.log文件。  
编译参数参考:

[plain]  view plain copy
  1. BUILD_CONFIG   采用官方发行版一致的编译参数  
  2. CMAKE_BUILD_TYPE 指定产品编译说明信息   RelWithDebInf  
  3. CMAKE_INSTALL_PREFIX 指定MySQL安装路径  /usr/local/mysql  
  4. CPACK_MONOLITHIC_INSTALL是否建立单个安装包文件 OFF   5.6.7  
  5. DEFAULT_CHARSET  MYSQL 默认字符集  latin1   5.6.7  
  6. DEFAULT_COLLATION MYSQL 默认排序字符集  latin1_swedish_ci 5.6.7  
  7. ENABLE_DEBUG_SYNC 是否启用同步调试功能  ON   5.6.7  
  8. ENABLE_DOWNLOADS 是否下载可选文件  OFF   5.6.7  
  9. ENABLE_DTRACE  是否包含 DTrace 支持     5.6.7  
  10. ENABLE_GCOV  是否包含 Gcov 支持     5.5.14  
  11. ENABLED_LOCAL_INFILE 是否启用本地 LOAD DATA INFILE OFF   5.6.7  
  12. ENABLED_PROFILING 是否启用代码查询分析  ON   5.6.7  
  13. INSTALL_BINDIR  MySQL 主执行文件目录  PREFIX/bin  5.6.7  
  14. INSTALL_DOCDIR  文档安装路径   PREFIX/docs  5.6.7  
  15. INSTALL_DOCREADMEDIR 自述文件目录   PREFIX   5.6.7  
  16. INSTALL_INCLUDEDIR 头文件目录   PREFIX/include  5.6.7  
  17. INSTALL_INFODIR  关于信息文件目录  PREFIX/docs  5.6.7  
  18. INSTALL_LAYOUT  选择预定义的安装  STANDALONE  5.6.7  
  19. INSTALL_LIBDIR  库文件目录   PREFIX/lib  5.6.7  
  20. INSTALL_MANDIR  手册页面目录   PREFIX/man  5.6.7  
  21. INSTALL_MYSQLSHAREDIR 共享数据目录   PREFIX/share  5.6.7  
  22. INSTALL_MYSQLTESTDIR mysql-test 目录   PREFIX/mysql-test 5.6.7  
  23. INSTALL_PLUGINDIR 插件目录   PREFIX/lib/plugin 5.6.7  
  24. INSTALL_SBINDIR  服务器超级用户执行文件目录 PREFIX/bin  5.6.7  
  25. INSTALL_SCRIPTDIR 脚本目录   PREFIX/scripts  5.6.7  
  26. INSTALL_SHAREDIR aclocal/mysql.m4 安装目录 PREFIX/share  5.6.7  
  27. INSTALL_SQLBENCHDIR sql-bench 性能测试工具目录 PREFIX   5.6.7  
  28. INSTALL_SUPPORTFILESDIR 扩展支持文件目录  PREFIX/support-files 5.6.7  
  29. MYSQL_DATADIR  数据库存放目录      5.6.7  
  30. MYSQL_MAINTAINER_MODE 是否启用MySQL的维护环境  OFF   5.6.7  
  31. MYSQL_TCP_PORT  TCP/IP 端口号   3306   5.6.7  
  32. MYSQL_UNIX_ADDR  Unix Socket 套接字文件  /tmp/mysql.sock  5.6.7  
  33. SYSCONFDIR  选项配置文件目录     5.6.7  
  34. WITH_COMMENT  编译环境发表评论     5.6.7  
  35. WITH_DEBUG  是否包括调试支持  OFF   5.6.7  
  36. WITH_EMBEDDED_SERVER 是否要建立嵌入式服务器  OFF   5.6.7  
  37. WITH_xxx_STORAGE_ENGINE 静态编译xxx 存储引擎到服务器    5.6.7  
  38. WITH_EXTRA_CHARSETS 额外的字符集,包括  all   5.6.7  
  39. WITH_LIBWRAP  是否包括支持libwrap(TCP包装) OFF   5.6.7  
  40. WITH_READLINE  使用捆绑的readline  OFF   5.6.7  
  41. WITH_SSL  是否支持SSL  no   5.6.7  
  42. WITH_ZLIB  是否支持Zlib  system   5.6.7  
  43. WITHOUT_XXX_STORAGE_ENGINE 不编译XXX存储引擎到数据库  

备注日志1:

[plain]  view plain copy
  1. Installing MySQL system tables...2015-11-15 18:18:41 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).  
  2. 2015-11-15 18:18:41 0 [Note] /usr/local/mysql/bin/mysqld (mysqld 5.6.27) starting as process 19263 ...  
  3. 2015-11-15 18:18:41 19263 [Note] InnoDB: Using atomics to ref count buffer pool pages  
  4. ………………  
  5. ………………  
  6. The latest information about MySQL is available on the web at  
  7.   
  8.   http://www.mysql.com  
  9.   
  10. Support MySQL by buying support/licenses at http://shop.mysql.com  
  11.   
  12. New default config file was created as /usr/local/mysql/my.cnf and  
  13. will be used by default by the server when you start it.  
  14. You may edit this file to change server settings  

备注日志2:

[plain]  view plain copy
  1. [root@tsxs data]# ps -ef | grep mysql  
  2. root     14043     1  0 19:30 pts/1    00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/data --pid-file=/data/tsxs.pid  
  3. mysql    14158 14043  0 19:30 pts/1    00:00:00 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/data/tsxs.err --pid-file=/data/tsxs.pid  
  4. root     14191   958  0 19:35 pts/0    00:00:00 grep mysql  

备注图片1,2:



编译 ./configure --prefix=/usr/local/php --exec-prefix=/usr/local/php --bindir=/usr/local/php/bin --sbindir=/usr/local/php/sbin --includedir=/usr/local/php/include --libdir=/usr/local/php/lib/php --mandir=/usr/local/php/php/man --with-config-file-path=/usr/local/php/etc --with-mysql-sock=/var/run/mysql/mysql.sock --with-mcrypt=/usr /i nclude --with-mhash --with-openssl --with-mysql=shared,mysqlnd --with-mysqli=shared,mysqlnd --with-pdo-mysql=shared,mysqlnd --with-gd --with-iconv --with-zlib --enable-zip --enable-inline-optimization --disable-debug --disable-rpath --enable-shared --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-mbregex --enable-mbstring --enable-ftp --enable-gd-native-ttf --enable-pcntl --enable-sockets --with-xmlrpc --enable-soap --without-pear --with-gettext --enable-session --with-curl --with-jpeg-dir --with-freetype-dir --enable-opcache --enable-fpm --enable-fastcgi --with-fpm-user=www --with-fpm-group=www --without-gdbm --with-mcrypt=/usr/local/apps/libmcrypt --disable-fileinfo 报错:1, **configure: error: system libzip must be upgraded to version >=**0.11。 使用Yum最新版只到0.10,不足以达到要求。 一、先删除libzip yum remove libzip -y SSH执行以上命令,先删除libzip 和 libzip-devel 二、下载安装并手动编译 wget https://nih.at/libzip/libzip-1.2.0.tar.gz tar -zxvf libzip-1.2.0.tar.gz cd libzip-1.2.0 ./configure make && make install 三、(可忽略)另外最新版本请参考官网:https://nih.at/libzip/ 1.5.0的libzip需要cmake wget https://libzip.org/download/libzip-1.5.0.tar.gz tar -zxvf libzip-* cd libzip* mkdir build && cd build && cmake .. && make && make install 报错2: error: off_t undefined; check your library configuration 根据报错信息分析 configure: error: off_t undefined; check your library configuration 未定义的类型 off_t。 off_t 类型是在 头文件 unistd.h中定义的,在32位系统 编程成 long int ,64位系统则编译成 long long int ,这里题主的系统应该是 64位的吧,在进行编译的时候 是默认查找64位的动态链接库,但是默认情况下 centos 的动态链接库配置文件/etc/ld.so.conf里并没有加入搜索路径,这个时候需要将 /usr/local/lib64 /usr/lib64 这些针对64位的库文件路径加进去。 采用下面的方法。 添加搜索路径到配置文件 echo '/usr/local/lib64 /usr/local/lib /usr/lib /usr/lib64'>>/etc/ld.so.conf 然后 更新配置 ldconfig -v 再次执行 编译 成功 执行安装: make && make install 报错: /usr/local/include/zip.h:59:21: fatal error: zipconf.h: No such file or directory 解决: cp /usr/local/lib/libzip/include/zipconf.h /usr/local/include/zipconf.h 1 安装成功: 复制配置文件: cp php.ini-production /usr/local/php/lib/php.ini cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf ln -s /usr/local/php/sbin/php-fpm /usr/local/bin 修改配置: cd /usr/local/php/etc/php-fpm.d vim www.conf [www] //池子名 (pool) 设置 ;listen = /tmp/php-fcgi.sock // 监听的地址,可以监听socket ,也可以监听端口 listen = 127.0.0.1:8089 或者这样写,php-fpm 通常在本地使用,php和nginx 通常在一台机器,所以可写127.0.0.1,别的机器 连接,需用本机ip listen.mode = 666 //sock 文件的权限 listen.owner = nobody listen.group = nobody user = php-fpm group = php-fpm pm = dynamic pm.max_children = 50 pm.start_servers = 20 pm.min_spare_servers = 5 pm.max_spare_servers = 35 pm.max_requests = 500 rlimit_files = 1024 加入 systemtl 服务: cd /usr/local/src/php-7.3.0beta1/sapi/fpm cp php-fpm.service /usr/lib/systemd/system/ 启动: systemctl start php-fpm systemctl status php-fpm -l
tar zxvf php-5.6.37.tar.gz cd php-5.6.37 #添加组 groupadd www #添加php-fpm用户 useradd -c php-fpm-user -g www -M www # c和c++编译器 yum -y install -y gcc gcc-c++ # PHP扩展依赖 yum install -y libxml2-devel openssl-devel libcurl-devel libjpeg-devel libpng-devel libicu-devel openldap-devel ./configure --prefix=/usr/local/php \ --with-config-file-path=/usr/local/php/etc \ --enable-fpm\ --with-fpm-user=www\ --with-fpm-group=www\ --enable-mysqlnd\ --with-mysql=mysqlnd\ --with-mysqli=mysqlnd\ --with-pdo-mysql=mysqlnd\ --enable-opcache\ --enable-pcntl\ --enable-mbstring\ --enable-soap\ --enable-zip\ --enable-calendar\ --enable-bcmath\ --enable-exif\ --enable-ftp\ --enable-intl\ --with-openssl\ --with-zlib\ --with-curl\ --with-gd\ --with-zlib-dir=/usr/lib\ --with-png-dir=/usr/lib\ --with-jpeg-dir=/usr/lib\ --with-gettext\ --with-mhash\ --with-ldap make && make install cp php.ini-production /usr/local/php/etc/php.ini cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm # 设置php-fpm开机自动启动 chmod +x /etc/init.d/php-fpm chkconfig php-fpm on cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf service php-fpm start 设置php为全局命令: 修改/etc/profile文件使其永久性生效,并对所有系统用户生效, 在文件末尾加上如下两行代码: PATH=$PATH:/usr/local/php/bin //php命令路径 如果还要同时加入mysql 则第一句: PATH=$PATH:/usr/local/php/bin:/usr/local/mysql/bin //路径一定要正确 执行 命令source /etc/profile 使用php -V确认 【查看php-fpm端口】 vim /usr/local/php/etc/php-fpm.conf listen = 127.0.0.1:9000
mysql-5.6.25.tar 包含两个文件: - mysql-5.6.25.tar.gz Generic Linux (Architecture Independent), Compressed TAR Archive MD5: 37664399c91021abe070faa700ecd0ed -install.txt: 安装方法 首先解压mysql-5.6.25.tar: $ tar xf mysql-5.6.25.tar ------------------ Mysql 源码安装操作: 1. 创建用户 # groupadd mysql # useradd -g -r mysql mysql 2. 解压缩tar包 # tar xf mysql-5.6.25.tar.gz # cd mysql-5.6.25 3. 编译安装 # cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \ > -DDEFAULT_CHARSET=gbk \ > -DDEFAULT_COLLATION=gbk_chinese_ci \ > -DENABLED_LOCAL_INFILE=ON \ > -DWITH_INNOBASE_STORAGE_ENGINE=1 \ > -DWITH_FEDERATED_STORAGE_ENGINE=1 \ > -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \ > -DMYSQL_UNIX_ADDR=/tmp/mysqld.sock \ > -DWITH_DEBUG=0 \ > -DMYSQL_TCP_PORT=3306 # make # make install 4. 配置以及初始化MySQL # cd /usr/local/mysql 4.1 设置MySQL安装目录的权限 # chown -R mysql:mysql /usr/local/mysql 4.2 初始化MySQL # scripts/mysql_install_db --user=mysql # cp support-files/mysql.server /etc/init.d/mysqld 4.3 重新设置MySQL安装目录的权限(除data目录外,其余所有目录及文件均修改用户为root,组不变) # chown -R root . # chown -R mysql data 4.4 启动mysql_safe # bin/mysqld_safe --user=mysql & 4.5 设置MySQL的root帐号密码 - 自动设置:# ./bin/mysql_secure_installation 或 - 手动置:# ./bin/mysqladmin -u root password '' ------------------ 操作详情参看: https://github.com/Marslo/MyBlog/blob/master/Programming/MySQL/MySQLInstallationBySourceCode.md MySQL6源码安装官方手册: http://dev.mysql.com/doc/refman/5.6/en/installing-source-distribution.html ------------------ 资源为英文,下载请谨慎
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值