mysql源代码安装细说

mysql为我们提供了三种安装方式:二进制、rpm、源代码编译。这里我们详细讨论mysql的源代码编译安装方式。

在5.5版本之后,mysql不再提供configure编译方式,改为使用cmake编译工具,cmake工具的一个显著特点是其编译独立于源代码,即我们可以在源代码之外的目录使用cmake来编译mysql,如

[[email protected] tmp]# ls -l | grep mysql
drwxr-xr-x  2 root root         4096 4月  29 21:11 mysql2
drwxr-xr-x 33 7161 wheel        4096 3月  15 03:07 mysql-5.6.17
-rw-r--r--  1 easy oinstall 32862539 4月  23 20:52 mysql-5.6.17.tar.gz
drwx------  2 easy oinstall     4096 4月  27 22:43 mysql-workbench.easy
[[email protected] tmp]# cd mysql2
[[email protected] mysql2]# cmake ../mysql-5.6.17

这样我们便可以在不同的目录下对源文件进行多次编译,而相互不影响。

使用cmake,可以通过 -LAH来获取所有的编译选项

[[email protected] mysql1]# cmake ../mysql-5.6.17 -LAH
-- Running cmake version 2.6.4
-- MySQL 5.6.17
-- Packaging as: mysql-5.6.17-Linux-x86_64
-- HAVE_VISIBILITY_HIDDEN
-- HAVE_VISIBILITY_HIDDEN
-- HAVE_VISIBILITY_HIDDEN
-- Using cmake version 2.6.4
-- Not building NDB
-- Library mysqlclient depends on OSLIBS -lpthread;m;rt;dl
-- Library mysqlserver depends on OSLIBS -lpthread;m;rt;crypt;dl;aio
-- Configuring done
-- Generating done
-- Build files have been written to: /tmp/mysql1
-- Cache values
// path to the executable
ACLOCAL_EXECUTABLE:FILEPATH=/usr/bin/aclocal

.....

// Missing description
WITH_ZLIB:STRING=bundled

如果要清除编译信息,可以使用如下命令:

[[email protected] mysql1]# make clean
[[email protected] mysql1]# rm CMakeCache.txt
rm:是否删除普通文件 "CMakeCache.txt"?y

编译选项:

部分选项使用来指定编译过程中使用的可执行文件的路径,如 ACLOCAL_EXECUTABLE:FILEPATH=/usr/bin/aclocal,大家可以自己研究,这里不再獒述。

-DBUILD_CONFIG=mysql_release

使用该选项,可以促使编译器按照oracle生成官方版本的选项来编译程序,例子:

cmake -DBUILD_CONFIG=mysql_release

?

-DCMAKE_BUILD_TYPE=type

该选项具有两个选择值

? RelWithDebInfo: 默认值,启用optimizations,同时生成调试信息

? Debug: 禁用optimizations, 同时生成调试信息,与-DWITH_DEBUG=1 具有相同的效果

?

-DCPACK_MONOLITHIC_INSTALL=bool

该选项影响make package操作的行为,如果设置为真,生成单个文件,否则生成多个文件。默认是生成多个文件

The CMAKE_INSTALL_PREFIX option indicates the base installation directory. Other options with

names of the form INSTALL_xxx that indicate component locations are interpreted relative to the

prefix and their values are relative pathnames. Their values should not include the prefix.

?

-DCMAKE_INSTALL_PREFIX=dir_name

该选项指定了mysql的安装目录,除了在编译时指定此值,我们也可月使用--basedir在mysql启动时设置基准目录。在编译时,INSTALL_XXX格式的选项是相对于PREFIX的相对路径,这是需要注意的一点

?

-DINSTALL_BINDIR=dir_name

bin文件的目录

?

-DINSTALL_LAYOUT=name

使用何种已经预设好的文件布局,我们可以在这些的布局的基础上,再手工设定某些目录的位置

? STANDALONE: Same layout as used for .tar.gz and .zip packages. This is the default.

? RPM: Layout similar to RPM packages.

? SVR4: Solaris package layout.

? DEB: DEB package layout (experimental).

如下

shell> cmake . -DINSTALL_LAYOUT=SVR4 -DMYSQL_DATADIR=/var/mysql/data

?

-DINSTALL_MYSQLTESTDIR=dir_name

Where to install the mysql-test directory. As of MySQL 5.6.12, to suppress installation of this

directory, explicitly set the option to the empty value (-DINSTALL_MYSQLTESTDIR=).

?

-DINSTALL_SQLBENCHDIR=dir_name

Where to install the sql-bench directory. To suppress installation of this directory, explicitly set the

option to the empty value (-DINSTALL_SQLBENCHDIR=).

?

-DMYSQL_DATADIR=dir_name

指定数据文件的位置,也可以安装后使用--datadir来设置

?

-DODBC_INCLUDES=dir_name

The location of the ODBC includes directory, and may be used while configuring Connector/ODBC.(配置odbc时可能会使用)

?

-DODBC_LIB_DIR=dir_name

The location of the ODBC library directory, and may be used while configuring Connector/ODBC.

?

-DSYSCONFDIR=dir_name

The default my.cnf option file directory. This location cannot be set at server startup, but you can start the server with a given option file using the --defaults-file=file_name option, where file_name is the full path name to the file.

在编译mysql时,我们可以指定如何将存储引擎编译进mysql:静态编译和动态编译。个人认为静态编译的服务器效率会高一些。

默认情况下MyISAM, MERGE, MEMORY, CSV 四种存储引擎是必须的,并且会静态编译进服务器中。如果我们需要静态编译其他存储引擎可以使用如下参数

-DWITH_engine_STORAGE_ENGINE=1

这里的engine可以取值ARCHIVE, BLACKHOLE, EXAMPLE, FEDERATED, INNOBASE,NDB or NDBCLUSTER (NDB), PARTITION (partitioning support), and PERFSCHEMA(Performance Schema).

我们也可以显示排除某种存储引擎,如

-DWITHOUT_engine_STORAGE_ENGINE=1.

如果对于某种引擎即没有显示引入也没有显示排除,mysql会将该引擎编译成共享模块,如果无法编译成共享模块,则排除该引擎。

-DDEFAULT_CHARSET=charset_name

指定数据库的默认字符集,字符集的取值可以在cmake/charset-sets.cmake下找到

-DDEFAULT_COLLATION=collation_name

指定数据库的排序方式,可以在数据库启动时通过--collation_server选项来指定,通过show collation命令可以查看可选的排序方式

-DENABLE_DEBUG_SYNC=bool

用于开启mysql的同步调试功能,默认情况下,该功能是开启的,但是只有在mysql配置为启用调试时才会生效。既是启用了该功能,在运行时该功能亦是关闭的,需要使用--debug-sync-timeout=N 选项来启动mysql服务器才可以,默认n为0,即该功能禁用,如果n大于0,在同步调试会等待n时间单位,否则会超时。

?

-DENABLE_DOWNLOADS=bool

用来下载一些可选文件,如google的测试分支等。

-DENABLE_DTRACE=bool

是否启用dtrace

?

-DENABLE_GCOV=bool

Whether to include gcov support (Linux only).

?

-DENABLE_GPROF=bool

Whether to enable gprof (optimized Linux builds only). This option was added in MySQL 5.6.6.

?

-DENABLED_LOCAL_INFILE=bool

使mysql客户端具有load data infile的功能,该功能具有安全隐患,

?

-DENABLED_PROFILING=bool

是否启用PROFILING功能,建议开启,用于性能监视

?

-DIGNORE_AIO_CHECK=bool

If the -DBUILD_CONFIG=mysql_release option is given on Linux, the libaio library must be

linked in by default. If you do not have libaio or do not want to install it, you can suppress the

check for it by specifying -DIGNORE_AIO_CHECK=1. This option was added in MySQL 5.6.1.

?

-DINNODB_PAGE_ATOMIC_REF_COUNT=bool

Whether to enable or disable atomic page reference counting. Fetching and releasing pages from the buffer pool and tracking the page state are expensive and complex operations. Using a page

mutex to track these operations does not scale well. With INNODB_PAGE_ATOMIC_REF_COUNT=ON (default), fetch and release is tracked using atomics where available. For platforms that do not

support atomics, set INNODB_PAGE_ATOMIC_REF_COUNT=OFF to disable atomic page reference counting.

When atomic page reference counting is enabled (default), “[Note] InnoDB: Using atomics

to ref count buffer pool pages” is printed to the error log at server startup. If atomic page reference counting is disabled, “[Note] InnoDB: Using mutexes to ref count buffer pool pages” is printed instead.

This build option was introduced with the fix for MySQL Bug #68079.

?

-DMYSQL_MAINTAINER_MODE=bool

Whether to enable a MySQL maintainer-specific development environment. If enabled, this option causes compiler warnings to become errors.

?

-DMYSQL_TCP_PORT=port_num

The port number on on which the server listens for TCP/IP connections. The default is 3306. This value can be set at server startup with the --port option.

-DMYSQL_UNIX_ADDR=file_name

The Unix socket file path on which the server listens for socket connections. This must be an absolute path name. The default is /tmp/mysql.sock.

This value can be set at server startup with the --socket option.

?

-DOPTIMIZER_TRACE=bool

Whether to support optimizer tracing. See MySQL Internals: Tracing the Optimizer. This option was added in MySQL 5.6.3.

?

-DWITH_ASAN=bool

Whether to enable AddressSanitizer, for compilers that support it. The default is off. This option was added in MySQL 5.6.15.

?

-DWITH_DEBUG=bool

Whether to include debugging support.

Configuring MySQL with debugging support enables you to use the --debug="d,parser_debug" option when you start the server. This causes the Bison parser that is used to process SQL statements to dump a parser trace to the server‘s standard error output. Typically,
this output is written to the error log.

?

-DWITH_DEFAULT_FEATURE_SET=bool

Whether to use the flags from cmake/build_configurations/feature_set.cmake. This

option was added in MySQL 5.6.6.

?

-DWITH_EDITLINE=value

Which libedit/editline library to use. The permitted values are bundled (the default) and

system.

WITH_EDITLINE was added in MySQL 5.6.12. It replaces WITH_LIBEDIT, which has been

removed.

?

-DWITH_EMBEDDED_SERVER=bool

Whether to build the libmysqld embedded server library.

?

-DWITH_EXTRA_CHARSETS=name

Which extra character sets to include:

? all: All character sets. This is the default.

? complex: Complex character sets.

? none: No extra character sets.

?

-DWITH_INNODB_MEMCACHED=bool

Whether to generate memcached shared libraries (libmemcached.so and innodb_engine.so).

?

-DWITH_LIBEVENT=string

Which libevent library to use. Permitted values are bundled (default), system, and yes. If

you specify system or yes, the system libevent library is used if present. If the system library

is not found, the bundled libevent library is used. The libevent library is required by InnoDB

memcached.

-DWITH_LIBEDIT=bool

Whether to use the libedit library bundled with the distribution.

WITH_LIBEDIT was removed in MySQL 5.6.12. Use WITH_EDITLINE instead.

?

-DWITH_LIBWRAP=bool

Whether to include libwrap (TCP wrappers) support.

?

-DWITH_READLINE=bool

Whether to use the readline library bundled with the distribution. This option was removed in

MySQL 5.6.5 because readline is no longer bundled.

?

-DWITH_UNIXODBC=1

Enables unixODBC support, for Connector/ODBC.

?

-DWITH_ZLIB=zlib_type

Some features require that the server be built with compression library support, such as the

COMPRESS() and UNCOMPRESS() functions, and compression of the client/server protocol. The

WITH_ZLIB indicates the source of zlib support:

? bundled: Use the zlib library bundled with the distribution.

? system: Use the system zlib library. This is the default.

?

-DWITHOUT_SERVER=bool

Whether to build without the MySQL server. The default is OFF, which does build the server.

了解了各个选项的意义,下面就可以执行安装了

# Preconfiguration setup
shell> groupadd mysql
shell> useradd -r -g mysql mysql
# Beginning of source-build specific instructions
shell> tar zxvf mysql-VERSION.tar.gz
shell> cd mysql-VERSION
shell> cmake .
shell> make
shell> make install
# End of source-build specific instructions
# Postinstallation setup
shell> cd /usr/local/mysql
shell> chown -R mysql .
shell> chgrp -R mysql .
shell> scripts/mysql_install_db --user=mysql
shell> chown -R root .
shell> chown -R mysql data
shell> bin/mysqld_safe --user=mysql &
# Next command is optional
shell> cp support-files/mysql.server /etc/init.d/mysql.server

mysql源代码安装细说

时间: 2024-11-09 06:42:02

mysql源代码安装细说的相关文章

mysql在linux上的安装之二(mysql源代码安装)

1.下载对应的mysql安装源代码包 地址为:http://dev.mysql.com/downloads/mysql/5.1.html 2.假设曾经安装过则卸载无用过旧的已安装的mysql 因为非常多linux发行版,都预装了对应的mysql,一般都是rpm形式的安装,且mysql的版本号都是比較低的(这个可能是因为兼容性測试的考虑吧).因此在自己亲自安装mysql之前,请先卸载这些过旧的mysql,保证我们系统的"纯净". 使用例如以下命令查询系统中安装的mysql: rpm -q

MySQL 源代码scr.rpm安装的一点注意事项

rpm安装包通常为二进制包(Binary)以及源代码包(Source)两种形式. 在使用源代码方式安装MySQL的时候,官方站点上下载的源代码包通常为scr.rpm格式,而不是直接的tar包.对此,须要先使用rpm命令先安装源代码后在进行编译安装.本文是对该方式的描写叙述. 1.下载源代码包  http://mirrors.sohu.com/mysql/MySQL-5.6/  http://dev.mysql.com/downloads/mysql/ 2.安装rpm#环境suse11:~ # c

源代码安装软件-MySQL

一.源码安装 1.经典的源代码安装三步曲: 1.编译前的配置 ./configure 2.编译 make 3.安装 make install 2.源代码软件安装步骤: 1.下载软件包 2.校验软件包 3.解包 4.进入解包得到的目录 5.认真阅读README和INSTALL文件 6.按照README或者INSTALL文件中的安装步骤进行安装 实验环境搭建: 1.basic server安装选项 2.配置磁盘80G,swap 1024M,其他分配给/分区 3.安装完成以后,配置网络 主机名字.IP

源代码安装Mysql

实验运行环境:centos-6.5  软件包mysql-5.6.10.tar  mysql-5.5.15-linux2.6-i686.tar  cmake-2.8.10.2.tar 安装源代码MySQL 1首先到MySQL官网下载最新版的MySQL安装包的源代码 2.安装之前查看你的系统上关于MySQL相关的软件包,把它卸载掉(不然会影响到MySQL的安装) 3.解压包MySQL到/usr/local/src下,打开INSTALL-SOURCE 查看安装帮助信息 **** 接下来可以用cmake

mysql分析(一)源代码安装及简单调试

一.源代码安装安装方式有两种,一种是二进制文件的安装,另一种是源代码级别安装.不同的二进制安装只是将同一份源代码在不同的机器上编译并且按照指定的运行格式进行尽量简单的配置,所以二进制安装的发行包命名中包含有操作系统的信息,源代码发行版本中中只有版本信息,不包含OS信息.在下载的5.5.28版本自带的INSTALL-SOURCE文件中的一些摘录内容       Standard distributions are available as compressed tar files,       Z

mysql的源代码安装

groupadd mysql useradd -g mysql mysql cd /usr/local tar zxvf /root/mysql-5.0.22.tar.gz # MySQL 源代码包的绝对路径 cd mysql-5.0.22 ./configure --enable-thread-safe-client --with-unix-socket --with-mysqld-user=mysql --with-charset=gbk --prefix=/usr/local/mysql

Windows下MySQL下载安装、配置与使用

用过MySQL之后,不论容量的话,发现比其他两个(sql server .oracle)好用的多,一下子就喜欢上了.下面给那些还不知道怎么弄的童鞋们写下具体的方法步骤. (我这个写得有点太详细了,甚至有些繁琐,有很多步骤在其他的教程文档里都是省略掉的,但我还是要写出来,因为我当时走了很多弯路,我希望你们能够避免我走的这些弯路.当然,知道同学的可以略过,选择你想知道的地方看) 第一大步:下载.(不需要注册也可以下载,直接点下面的no thanks) a.俗话说:“巧妇难为无米之炊”嘛!我这里用的是

Python 3 mysql 简介安装

Python 3 mysql 简介安装 一.数据库是什么 1.  什么是数据库(DataBase,简称DB) 数据库(database,DB)是指长期存储在计算机内的,有组织,可共享的数据的集合.数据库中的数据按一定的数字模型组织.描述和存储,具有较小的冗余,较高的数据独立性和易扩展性,并且可为各种用户共享. 2.什么是数据(Data) 描述事物的符号记录称为数据,描述事物的符号既可以是数字,也可以是文字.图片,图像.声音.语言等,数据由多种表现形式,它们都可以经过数字化后存入计算机 在计算机中

转:MySQL下载安装、配置与使用(win7x64)

1 第一大步:下载. a.俗话说:"巧妇难为无米之炊"嘛!我这里用的是 ZIP Archive 版的,win7 64位的机器支持这个,所以我建议都用这个.因为这个简单嘛,而且还干净. 地址见图 拉倒最下面,看清楚了64bit ZIP Archive ,点击Download. 2 b.点开之后会进入另一个页面,但却没有开始下载,这个时候不用怕,看不懂没关系,你只要知道他是要让你们登录(login),或者 申请账号(sign up)个就行了,登录或者申请成功后就会开始下载.(记住密码要字母