search
HomeDatabaseMysql Tutorial源码编译安装MySQL5.6.10最佳实践

源码编译安装MySQL5.6.10最佳实践

Jun 07, 2016 pm 04:19 PM
InstallpracticeoptimalSource codecompile

1安装cmake MySQL从5.5版本开始,通过./configure进行编译配置方式已经被取消,取而代之的是cmake工具。 因此,我们首先要在系统中源码编译安装cmake工具。 # wget # tar zxvf cmake-2.8.7.tar.gz # cd cmake-2.8.7 # ./configure # make # make install 1.1

   1安装cmake

  MySQL从5.5版本开始,通过./configure进行编译配置方式已经被取消,取而代之的是cmake工具。

  因此,我们首先要在系统中源码编译安装cmake工具。

  # wget

  # tar zxvf cmake-2.8.7.tar.gz

  # cd cmake-2.8.7

  # ./configure

  # make

  # make install

  1.1cmake命令语法

  1.2重新编译时,需要清除旧的对象文件和缓存信息

  # make clean

  # rm -f CMakeCache.txt

  1.3安装选项

  CMAKE_INSTALL_PREFIX值是安装的基本目录,其他cmake选项值是不包括前缀,是相对路径名,绝对路径包括CMAKE_INSTALL_PREFIX路径。如-DINSTALL_SBINDIR=sbin的绝对路径是/usr/local/mysql /sbin

  1.4存储引擎选项

  mysql存储引擎是插件式的,因此插件控制选项可以指定那个存储引擎安装。

  configure编译插件选项--with-plugins=csv,myisam,myisammrg,heap,innobase,archive,blackhole在cmake中没有直接对应的相同选项。对于csv,myisam,myisammrg,heap在cmake中是不需要明确指定存储引擎的名称,因为它们是强制性安装。

  可以使用以下选择来安装innodb,archive,blackhole存储引擎

  -DWITH_INNOBASE_STORAGE_ENGINE=1

  -DWITH_ARCHIVE_STORAGE_ENGINE=1

  -DWITH_BLACKHOLE_STORAGE_ENGINE=1

  (1可以使用on代替)

  如果既不是-DWITH__STORAGE_ENGINE也不是-DWITHOUT__STORAGE_ENGINE 来指定存储引擎,该存储引擎将安装成共享模块式的。如果不是共享模块式的将排除在外。共享模块安装时必须使用INSTALL PLUGIN语句或--plugin-load才可以使用。

  有关插件的CMake的选项的其他信息,请查阅:

  1.5 lib库选项

  1.6其他选项

  之前MySQL的编译选项大多数都支持。新旧版本之间的安装选项映射成大写字母,删除选项前面破折号,中间字符间的破折号替换成下划线。如:

  --with-debug => WITH_DEBUG=1

  --with-embedded-server => WITH_EMBEDDED_SERVER

  1.7调试配置过程

  使用configure编译完将生成config.log和config.status文件。

  使用cmake编译完在CMakeFiles目录下生成CMakeError.log 和CMakeOutput.log文件。

  1.8第三方接口工具

  在之前的版本,第三方工具从MySQL顶层源目录中读取源configure.in文件来确定mysql版本。如:对5.5.7 - RC版本的AC_INIT线看起来像这样:

  AC_INIT([MySQLServer], [5.5.7-rc], [], [mysql])

  现在的版本可以直接读取版本文件。如:如果版本是5.5.8,,文件看起来像这样的:

  MYSQL_VERSION_MAJOR=5

  MYSQL_VERSION_MINOR=5

  MYSQL_VERSION_PATCH=8

  MYSQL_VERSION_EXTRA=rc

  如果源码包不是GA版,MYSQL_VERSION_EXTRA的值将非空。如:对于一个发布RC版本是这样的: MYSQL_VERSION_EXTRA=rc

  构建5位数字的版本号,使用下面公式:

  MYSQL_VERSION_MAJOR*10000+ MYSQL_VERSION_MINOR*100 + MYSQL_VERSION_PATCH

  2验证安装依赖

  通过 rpm -qa | grep name的方式验证以下软件包是否已全部安装。

  gcc* gcc-c++* autoconf* automake* zlib*libxml* ncurses-devel* libmcrypt* libtool*

  通过yum安装示例

  例:yum install gcc gcc-c++

  例:yum install ncurses-devel

  如果缺少相关的软件包,可通过yum -y install的方式在线安装,或直接从系统安装光盘中找到并通过rpm -ivh的方式安装。

  3安装前的系统设置

  建立mysql安装目录及数据存放目录

  # mkdir /usr/mysql5.5

  # mkdir /usr/mysql5.5/data

  创建用户和用户组

  # groupadd mysql

  # useradd –gmysql mysql

  赋予数据存放目录权限

  # chown mysql:mysql –R /opt/mysql5.5/data

  4正式开始安装(从configure更换为cmake)

  我相信大多数人都已经习惯了之前的configure方式,并且所使用的参数也是比较个性化的,换成cmake之后,这一方面会带来不少的麻烦。

  还好,MySQL的官方网站提供了二者的参数对照表,我们可以尽可能的保留之前的参数,来编译配置新的MySQL版本。

  configure 与cmake参数对照指南:

  

  以我自己为例,之前我一直使用的参数为:

  ./configure --prefix=/opt/mysql/

  --sysconfdir=/opt/mysql/etc

  --localstatedir=/opt/mysql/data

  --with-tcp-port=3306

  --with-unix-socket-path=/tmp/mysqld.sock

  --with-mysqld-user=mysql

  --enable-assembler

  --with-extra-charsets=all

  --enable-thread-safe-client

  --with-big-tables

  --with-readline

  --with-ssl

  --with-embedded-server

  --enable-local-infile

  --with-plugins=partition,innobase,myisammrg

  经过与cmake的参数对照之后,去除掉已经被取消的参数(大多数是因为新版本已经默认启用),cmake的参数配置如下:

  cmake -DCMAKE_INSTALL_PREFIX=/opt/mysql

  -DSYSCONFDIR=/opt/mysql/etc

  -DMYSQL_DATADIR=/opt/mysql/data

  -DMYSQL_TCP_PORT=3306

  -DMYSQL_UNIX_ADDR=/tmp/mysqld.sock

  -DMYSQL_USER=mysql

  -DEXTRA_CHARSETS=all

  -DWITH_READLINE=1

  -DWITH_SSL=system

  -DWITH_EMBEDDED_SERVER=1

  -DENABLED_LOCAL_INFILE=1

  -DWITH_INNOBASE_STORAGE_ENGINE=1

  -DWITHOUT_PARTITION_STORAGE_ENGINE=1

  不带换行符的(只有一行)

  4.1参数:-DWITHOUT_PARTITION_STORAGE_ENGINE=1

  在64位机器上编译不过,会出现如下错误:(64位机器的浮点数运算上出错,导致找不着相应的函数)

  libsql.a(handler.cc.o): In function`get_ha_partition(partition_info*)’:

  /data/mysql-5.5.14/sql/handler.cc:269: undefined reference to`ha_partition::ha_partition(handlerton*, partition_info*)’

  /data/mysql-5.5.14/sql/handler.cc:271: undefined reference to`ha_partition::initialize_partition(st_mem_root*)’

  libsql.a(sql_partition_admin.cc.o): In function`Alter_table_truncate_partition_statement::execute(THD*)’:

  /data/mysql-5.5.14/sql/sql_partition_admin.cc:165: undefinedreference to `ha_partition::truncate_partition(Alter_info*, bool*)’

  collect2: ld returned 1 exit status

  make[2]: *** [sql/mysqld] Error 1

  make[1]: *** [sql/CMakeFiles/mysqld.dir/all] Error 2

  make: *** [all] Error 2

  4.2参数:-DWITH_SSL=bundled

  自mysql5.6.*及以后的版本都要默认带上此参数,否则编译不过 ,相关贴子:

  https://github.com/santisaez/powerstack/issues/49

  Use bundled SSL on CentOS-5

  4.3安装执行

  # tar xvf mysql-5.5.10.tar.gz

  # cd mysql-5.5.10

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
What are the different storage engines available in MySQL?What are the different storage engines available in MySQL?Apr 26, 2025 am 12:27 AM

MySQLoffersvariousstorageengines,eachsuitedfordifferentusecases:1)InnoDBisidealforapplicationsneedingACIDcomplianceandhighconcurrency,supportingtransactionsandforeignkeys.2)MyISAMisbestforread-heavyworkloads,lackingtransactionsupport.3)Memoryengineis

What are some common security vulnerabilities in MySQL?What are some common security vulnerabilities in MySQL?Apr 26, 2025 am 12:27 AM

Common security vulnerabilities in MySQL include SQL injection, weak passwords, improper permission configuration, and unupdated software. 1. SQL injection can be prevented by using preprocessing statements. 2. Weak passwords can be avoided by forcibly using strong password strategies. 3. Improper permission configuration can be resolved through regular review and adjustment of user permissions. 4. Unupdated software can be patched by regularly checking and updating the MySQL version.

How can you identify slow queries in MySQL?How can you identify slow queries in MySQL?Apr 26, 2025 am 12:15 AM

Identifying slow queries in MySQL can be achieved by enabling slow query logs and setting thresholds. 1. Enable slow query logs and set thresholds. 2. View and analyze slow query log files, and use tools such as mysqldumpslow or pt-query-digest for in-depth analysis. 3. Optimizing slow queries can be achieved through index optimization, query rewriting and avoiding the use of SELECT*.

How can you monitor MySQL server health and performance?How can you monitor MySQL server health and performance?Apr 26, 2025 am 12:15 AM

To monitor the health and performance of MySQL servers, you should pay attention to system health, performance metrics and query execution. 1) Monitor system health: Use top, htop or SHOWGLOBALSTATUS commands to view CPU, memory, disk I/O and network activities. 2) Track performance indicators: monitor key indicators such as query number per second, average query time and cache hit rate. 3) Ensure query execution optimization: Enable slow query logs, record and optimize queries whose execution time exceeds the set threshold.

Compare and contrast MySQL and MariaDB.Compare and contrast MySQL and MariaDB.Apr 26, 2025 am 12:08 AM

The main difference between MySQL and MariaDB is performance, functionality and license: 1. MySQL is developed by Oracle, and MariaDB is its fork. 2. MariaDB may perform better in high load environments. 3.MariaDB provides more storage engines and functions. 4.MySQL adopts a dual license, and MariaDB is completely open source. The existing infrastructure, performance requirements, functional requirements and license costs should be taken into account when choosing.

How does MySQL's licensing compare to other database systems?How does MySQL's licensing compare to other database systems?Apr 25, 2025 am 12:26 AM

MySQL uses a GPL license. 1) The GPL license allows the free use, modification and distribution of MySQL, but the modified distribution must comply with GPL. 2) Commercial licenses can avoid public modifications and are suitable for commercial applications that require confidentiality.

When would you choose InnoDB over MyISAM, and vice versa?When would you choose InnoDB over MyISAM, and vice versa?Apr 25, 2025 am 12:22 AM

The situations when choosing InnoDB instead of MyISAM include: 1) transaction support, 2) high concurrency environment, 3) high data consistency; conversely, the situation when choosing MyISAM includes: 1) mainly read operations, 2) no transaction support is required. InnoDB is suitable for applications that require high data consistency and transaction processing, such as e-commerce platforms, while MyISAM is suitable for read-intensive and transaction-free applications such as blog systems.

Explain the purpose of foreign keys in MySQL.Explain the purpose of foreign keys in MySQL.Apr 25, 2025 am 12:17 AM

In MySQL, the function of foreign keys is to establish the relationship between tables and ensure the consistency and integrity of the data. Foreign keys maintain the effectiveness of data through reference integrity checks and cascading operations. Pay attention to performance optimization and avoid common errors when using them.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.