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
网址:
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:
[root@tsxs installfiles]# tar zxvf cmake-3.3.2.tar.gz
[root@tsxs installfiles]# cd cmake-3.3.2
[root@tsxs cmake-3.3.2]# ls
Auxiliary CMakeCPack.cmake CMakeGraphVizOptions.cmake CMakeLogo.gif
CompileFlags.cmake CONTRIBUTING.rst CTestConfig.cmake DartConfig.cmake Help
Modules Source Tests bootstrap CMakeCPackOptions.cmake.in CMakeLists.txt
cmake_uninstall.cmake.in configure Copyright.txt CTestCustom.cmake.in doxygen.config
Licenses README.rst Templates Utilities
[root@tsxs cmake-3.3.2]# ./bootstrap
[root@tsxs cmake-3.3.2]# make
[root@tsxs cmake-3.3.2]# make install
测试:输入有关cmake的使用命令:
注:CMake是一个跨平台的安装(编译)工具,可以用简单的语句来描述所有平台的安装(编译过程)。 可以一次:make && make install
[root@tsxs installfiles]# cmake --version
[root@tsxs installfiles]# cmake --help
3:安装MySQL数据库:
MySQL数据库添加用户和组:
查看是否存在MySQL组:
[root@tsxs home]# grep mysql /etc/group
不存在创建MySQL组:
[root@tsxs home]# groupadd mysql
查看是否存在MySQL用户:
[root@tsxs home]# grep mysql /etc/passwd
不存在创建MySQL用户:
[root@tsxs ~]# useradd mysql -g mysql -M -s /sbin/nologin
检查:
[root@tsxs sbin]# grep mysql /etc/passwd
mysql:x:500:500::/home/mysql:/sbin/nologin
使用groups查看用户mysql所在的组
[root@tsxs sbin]# groups mysql
mysql : mysql
注:-g:指定新用户所属的用户组(group); -M:不建立根目录;-s:定义其使用的shell,/sbin/nologin代表用户不能登录系统。
注:也可以:
[root@Master home]# useradd mysql -g mysql -d /usr/local/mysql -s /bin/sh
如果有,请修改:
[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
解压:
[root@tsxs installfiles]# tar zxvf mysql-5.6.27.tar.gz
[root@tsxs installfiles]# cd mysql-5.6.27
[root@tsxs mysql-5.6.27]# ls
BUILD cmake config.h.cmake dbug extra
INSTALL-WIN-SOURCE libmysqld mysql-test packaging regex
sql-bench strings unittest win BUILD-CMAKE
CMakeLists.txt configure.cmake Docs include libevent
libservices mysys plugin scripts sql-common support-files
VERSION zlib client cmd-line-utils COPYING Doxyfile-perfschema
INSTALL-SOURCE libmysql man mysys_ssl README sql storage tests vio
准备安装目录:
安装MySQL目录:/usr/local/mysql
[root@tsxs local]# mkdir -p /usr/local/mysql
MySQL数据库目录:/data
[root@tsxs /]# mkdir /data
注:-p参数:如果一个目录的