当前位置: 首页 > 编程文章 >

SUSE Linux下源码编译安装MySQL 5.6详解

SUSE Linux下源码编译安装MySQL 5.6详解

作者:江辰时间:2025-11-01 11:04:00浏览:586

在SUSE Linux Enterprise Server 10 SP3环境下,通过源码方式安装MySQL 5.6.17。该过程涵盖系统环境确认、CMake构建工具及GCC等依赖项的安装,重点解决cmake配置时因缺少Curses库导致的报错问题。最终完成数据库初始化、权限配置及服务自启动设置,实现基于特定硬件和软件环境的定制化部署。

本文目录展开

源码安装MySQL的优势与环境准备

MySQL作为开源数据库,支持基于源码进行安装,这种方式提供了更高的灵活性。用户可以根据自身的硬件平台选择匹配的编译器以优化二进制代码,依据软件平台环境调整编译参数,按需选择安装组件,设定字符集等,从而针对特定应用场景进行各种定制调整。下文将介绍源码方式下的MySQL安装流程。

1、安装环境及介质 复制代码 代码如下: #安装环境 SZDB:~ # cat /etc/issue Welcome to SUSE Linux Enterprise Server 10 SP3 (x86_64) - Kernel \r (\l). SZDB:~ # uname -a Linux SZDB 2.6.16.60-0.54.5-smp #1 SMP Fri Sep 4 01:28:03 UTC 2009 x86_64 x86_64 x86_64 GNU/Linux #安装介质,可以到以下网址下载安装介质,注意下载时选择source code,当前版本为5.6.17 #根据你自身的环境下载相应的安装介质,本文演示的安装介质为Generic Linux (Architecture Independent), mysql-5.6.17.tar.gz http://dev.mysql.com/downloads/mysql/ #源码安装方式官方网站链接: http://dev.mysql.com/doc/refman/5.6/en/installing-source-distribution.html

系统需求与CMake工具安装

2、系统需求

复制代码 代码如下: Source Installation System Requirements Installation of MySQL from source requires several development tools. Some of these tools are needed no matter whether you use a standard source distribution or a development source tree. Other tool requirements depend on which installation method you use. To install MySQL from source, your system must have the following tools, regardless of installation method: CMake, which is used as the build framework on all platforms. CMake can be downloaded from http://www.cmake.org. A good make program. Although some platforms come with their own make implementations, it is highly recommended that you use GNU make 3.75 or newer. It may already be available on your system as gmake. GNU make is available from http://www.gnu.org/software/make/. A working ANSI C++ compiler. GCC 4.2.1 or later, Sun Studio 12 or later, Visual Studio 2010 or later, and many current vendor-supplied compilers are known to work. Perl is needed if you intend to run test scripts. Most Unix-like systems include Perl. On Windows, you can use a version such as ActiveState Perl. #使用源码安装上面的一些开发工具是需要的,比较重要的一个是Cmake工具,通常情况下os并没有安装,需要手动安装。 #如果没有cmake会收到这个错误提示:(-bash: cmake: command not found)

3、安装cmake

复制代码 代码如下: #可以到这里下载cmake,我这里下载的是2.6.4版本 http://www.cmake.org/cmake/resources/software.html SZDB:~ # cd /usr/local/src/mysql_src SZDB:/usr/local/src/mysql_src # tar -xvf cmake-2.6.4.tar.gz SZDB:/usr/local/src/mysql_src # cd cmake-2.6.4 SZDB:/usr/local/src/mysql_src/cmake-2.6.4 # ./bootstrap SZDB:/usr/local/src/mysql_src/cmake-2.6.4 # ./make SZDB:/usr/local/src/mysql_src/cmake-2.6.4 # ./make install

MySQL源码编译、初始化与服务配置

4、安装MySQL

复制代码 代码如下: SZDB:~ # groupadd mysql SZDB:~ # useradd -r -g mysql mysql SZDB:~ # cd /usr/local/src/mysql_src SZDB:/usr/local/src/mysql_src # tar -xvf mysql-5.6.17.tar.gz SZDB:/usr/local/src/mysql_src # ls mysql-5.6.17 mysql-5.6.17.tar.gz SZDB:/usr/local/src/mysql_src # cd mysql-5.6.17/ SZDB:/usr/local/src/mysql_src/mysql-5.6.17 # cmake . .......... -- Check size of wint_t - done -- Could NOT find Curses (missing: CURSES_LIBRARY CURSES_INCLUDE_PATH) CMake Error at cmake/readline.cmake:85 (MESSAGE): Author : Leshami Curses library not found. Please install appropriate package, Blog : http://blog.csdn.net/leshami 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:411 (MYSQL_CHECK_EDITLINE) #如果cmake期间碰到上述错误,应该安装ncurses-devel rpm包,然后移除CMakeCache.txt -- Configuring incomplete, errors occurred! #如有没有对应的os安装光盘,可以从下面的链接下载这个rpm包,注意对应的版本号应一致 http://www.filewatcher.com/m/ncurses-devel-5.5-18.11.x86_64.rpm.735840-0.html SZDB:/usr/local/src/mysql_src # rpm -Uvh ncurses-devel-5.5-18.11.x86_64.rpm Preparing... ########################################### [100%] 1:ncurses-devel ########################################### [100%] SZDB:/usr/local/src/mysql_src/mysql-5.6.17 # rm -rf CMakeCache.txt SZDB:/usr/local/src/mysql_src/mysql-5.6.17 # cmake . #再次执行cmake ........ -- Library mysqlserver depends on OSLIBS -lpthread;m;rt;crypt;dl;aio -- Configuring done -- Generating done -- Build files have been written to: /usr/local/src/mysql_src/mysql-5.6.17 SZDB:/usr/local/src/mysql_src/mysql-5.6.17 # make Linking CXX executable mysqltest_embedded [100%] Built target mysqltest_embedded Scanning dependencies of target my_safe_process [100%] Building CXX object mysql-test/lib/My/SafeProcess/CMakeFiles/my_safe_process.dir/safe_process.cc.o Linking CXX executable my_safe_process [100%] Built target my_safe_process SZDB:/usr/local/src/mysql_src/mysql-5.6.17 # make install SZDB:/usr/local/src/mysql_src/mysql-5.6.17 # cd /usr/local/mysql SZDB:/usr/local/mysql # chown -R mysql . SZDB:/usr/local/mysql # chgrp -R mysql . SZDB:/usr/local/mysql # scripts/mysql_install_db --user=mysql .......... To start mysqld at boot time you have to copy support-files/mysql.server to the right place for your system PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER ! To do so, start the server, then issue the following commands: ./bin/mysqladmin -u root password 'new-password' ./bin/mysqladmin -u root -h SZDB password 'new-password' Alternatively you can run: ./bin/mysql_secure_installation which will also give you the option of removing the test databases and anonymous user created by default. This is strongly recommended for production servers. See the manual for more instructions. You can start the MySQL daemon with: cd . ; ./bin/mysqld_safe & You can test the MySQL daemon with mysql-test-run.pl cd mysql-test ; perl mysql-test-run.pl New default config file was created as ./my.cnf and will be used by default by the server when you start it. You may edit this file to change server settings .......... SZDB:/usr/local/mysql # chown -R root . SZDB:/usr/local/mysql # chown -R mysql data SZDB:/usr/local/mysql # cp support-files/mysql.server /etc/init.d/mysql.server #配置自启动 SZDB:/usr/local/mysql # cp support-files/my-default.cnf /etc/my.cnf #添加缺省的my.cnf配置文件 SZDB:/usr/local/mysql # bin/mysqld_safe --user=mysql & #启动mysql [1] 21004 SZDB:/usr/local/mysql # 140521 02:54:54 mysqld_safe Logging to '/usr/local/mysql/data/SZDB.err'. 140521 02:54:54 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data #配置环境变量,通过软链或者修改环境变量实现(PATH=$PATH:/usr/local/mysql/bin/;export PATH) SZDB:~ # ln -fs /usr/local/mysql/bin/mysql /usr/local/bin SZDB:~ # ln -fs /usr/local/mysql/bin/mysqladmin /usr/local/bin SZDB:~ # ln -fs /usr/local/mysql/bin/mysqld_safe /usr/local/bin #登陆到mysql SZDB:/usr/local/bin # mysql -uroot Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 Server version: 5.6.17 Source distribution Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | test | +--------------------+ 4 rows in set (0.00 sec)

上一篇
MySQL InnoDB锁类型及原理深度解析

InnoDB支持表锁和行锁,通过索引实现行级锁定。本文详细解析共享锁、排他锁、意向锁及记录锁、间隙锁等算法,说明死锁产生条件与自动检测机制,并提供基于索引的加锁原理分析及避免死锁的最佳实践。

下一篇
MySQL事务隔离级别详解与读未提交测试示例

MySQL提供四种事务隔离级别:Read Uncommitted、Read Committed、Repeatable Read和Serializable。其中,Read Uncommitted允许读取未提交的数据,无法解决脏读问题。本文通过具体实验演示了在Read Uncommitted级别下,一个事务如何读取到另一个事务尚未提交的修改数据,从而验证了脏读现象的存在。

相关文章

更多
Linux主机AMH管理面板安装与建站指南

AMH是一款独立的LNMP/Nginx虚拟主机管理面板,支持Centos、Debian和Ubuntu系统。本文介绍如何在纯净Linux系统中通过脚本安装AMH 4.2版本,包括设置MySQL和管理员密码。安装完成后,通过Web端配置虚拟主机、绑定域名、创建FTP账号及数据库,即可快速搭建网站。

2026.11.13 999
Linux定时备份数据库并加密发送至指定邮箱

本文介绍在Linux环境下,通过配置mailutils和crontab实现MySQL数据库的自动化定时备份。内容涵盖网易126邮箱SMTP服务配置、mysqldump命令使用、Shell脚本编写以及利用zip命令对备份文件进行加密打包,最终将加密压缩包安全发送至指定邮箱。

2026.09.17 954
在Linux中利用Stow轻松管理源码安装的软件包

本文介绍如何使用Stow工具简化Linux系统中从源代码编译安装的软件包管理。通过指定prefix参数将文件集中存放并创建符号链接,用户可以在不保留源码的情况下,使用stow --delete命令一键移除已安装的软件,实现系统的干净卸载。

2025.07.08 896
Linux Docker安装WordPress的方法详解

本文介绍在Linux环境下利用Docker容器技术快速部署WordPress网站的方法。主要涵盖通过命令行直接创建MySQL和WordPress容器,以及使用Fig(现Compose)编排工具进行多容器应用管理两种方式。文中详细说明了环境变量配置、外部数据库连接及常用运维命令,帮助开发者高效搭建博客站点。

2025.09.11 829
Linux CentOS6.6源码编译安装MySQL 5.6详解

本文介绍在Linux CentOS6.6系统中通过源码包安装MySQL 5.6的完整流程。涵盖从下载源码、使用CMake进行依赖检查与参数配置,到创建专用用户、初始化数据目录及生成配置文件等核心步骤。同时详细解析了本地Socket连接失败及远程访问受限等常见错误的排查方法,并提供了将MySQL服务加入系统服务及设置开机自动启动的配置方案。

2025.05.25 826
CentOS 7配置MySQL源并安装MySQL完整指南

CentOS 7默认使用MariaDB,通过下载mysql57-community-release-el7-9.noarch.rpm包可配置官方YUM源。执行rpm安装后更新缓存,即可使用yum install命令安装mysql-community-server。启动服务后,需从/var/log/mysqld.log获取root临时密码登录,并通过ALTER USER语句设置包含大小写字母、数字和特殊字符的新密码以完成初始化。

2025.06.06 819

专题推荐

更多
PHP 类与对象定义及继承

先看类声明、对象实例与属性访问。理解对象的创建和销毁后,再读继承、方法重载和关键字对照。已有代码遇到继承行为差异时,可进一步查看 final 方法与反射实例。

PHP 定时任务配置与运行

先确定任务运行间隔以及是否允许重叠。固定时间触发先看 Cron 案例,框架内和常驻服务再读对应示例。

Yii2 队列配置与常驻运行

先用一个最小任务跑通入队和消费,再检查 Web 与 Console 是否加载了相同的队列配置。确认命令能手动运行后再配置 Supervisor,最后验证进程重启时的处理情况。

PHP Session 过期时间设置方法

浏览器关闭、服务端回收和业务规定的闲置超时,可能在不同时间发生。对照配置项与应用层时间戳的做法,检查会话何时仍可读、何时应要求重新登录。

PHP URL 编码和解码方法

URL 路径片段和查询参数对空格的处理方式不同。先比较 urlencode 与 rawurlencode,再沿解码过程核对中文、加号和百分号,检查地址是否被重复编码或提前解码。

在线工具箱

更多
键码查询
键码查询

按下键盘按键时查看浏览器记录的键名和事件信息。

.env 配置检查
.env 配置检查

本地检查 .env 键值语法、引号、重复键及空值,预览解析结果,辅助排查 PHP 和 Laravel 环境配置。

进制转换
进制转换

转换二进制、十进制、十六进制等数值表示,辅助程序调试与进制学习。

HTML 标签安全清理
HTML 标签安全清理

清理 HTML 片段中的标签或危险内容,辅助整理待展示的文本。

文件 Base64 转换
文件 Base64 转换

把文件转为 Base64 文本,也可将编码内容还原为文件,方便接口传输与调试。