mysql数据库的编译安装

mysql5.1之前编译mysql使用的是make工具,编译步骤如下:

./configure --prefix=

make &&make install

mysql5.5之后编译mysql使用的是cmake工具,编译步骤如下:

cmake .

查看帮助使用: cmake -LH 或ccmake .

1.创建mysql用户及安装依赖软件包.

[[email protected] mnt]# groupadd -r mysql

[[email protected] mnt]# useradd -r -g mysql  -s /sbin/nolog mysql

[[email protected] mnt]# id mysql

uid=101(mysql) gid=102(mysql) groups=102(mysql)

安装mysql依赖的软件包

yum install gcc gcc-c++ ncurses  ncurses-devel  openssl openssl-devel zlib bison cmake

到www.mysql.com下载mysql的源码包.

2.编译安装mysql

cd mysql源码目录

cmake .  -LH

若产生异常,可以删除CMakeCache.txt,重新执行cmake . -LH

[[email protected] mysql-5.5.38]# cmake . -LH

-- Running cmake version 2.6.4

-- MySQL 5.5.38

-- Packaging as: mysql-5.5.38-Linux-x86_64

-- Library mysqlclient depends on OSLIBS -lpthread;m;rt;dl

Warning: Bison executable not found in PATH

-- Configuring done

-- Generating done

-- Build files have been written to: /tmp/mysql-5.5.38

-- Cache values

// Choose the type of build, options are: None(CMAKE_CXX_FLAGS or

CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel

CMAKE_BUILD_TYPE:STRING=RelWithDebInfo

// install prefix

CMAKE_INSTALL_PREFIX:PATH=/usr/local/mysql

// Set to true if this is a community build

COMMUNITY_BUILD:BOOL=ON

// Enable profiling

ENABLED_PROFILING:BOOL=ON

// Enable debug sync (debug builds only)

ENABLE_DEBUG_SYNC:BOOL=ON

// Enable gcov (debug, Linux builds only)

ENABLE_GCOV:BOOL=OFF

// Installation directory layout. Options are: STANDALONE (as in zip or tar.gz installer), RPM, DEB, SVR4

INSTALL_LAYOUT:STRING=STANDALONE

// default MySQL data directory

MYSQL_DATADIR:PATH=/usr/local/mysql/data

// MySQL maintainer-specific development environment

MYSQL_MAINTAINER_MODE:BOOL=OFF

// PATH to MySQL TMP dir. Defaults to the P_tmpdir macro in <stdio.h>

TMPDIR:PATH=P_tmpdir

// Link ARCHIVE statically to the server

WITH_ARCHIVE_STORAGE_ENGINE:BOOL=OFF

// Enable address sanitizer

WITH_ASAN:BOOL=OFF

// Link BLACKHOLE statically to the server

WITH_BLACKHOLE_STORAGE_ENGINE:BOOL=OFF

// Use dbug/safemutex

WITH_DEBUG:BOOL=OFF

// Compile MySQL with embedded server

WITH_EMBEDDED_SERVER:BOOL=OFF

// Options are: none, complex, all

WITH_EXTRA_CHARSETS:STRING=all

// Link FEDERATED statically to the server

WITH_FEDERATED_STORAGE_ENGINE:BOOL=OFF

// Link INNOBASE statically to the server

WITH_INNOBASE_STORAGE_ENGINE:BOOL=ON

// Use bundled libedit

WITH_LIBEDIT:BOOL=ON

// Compile with tcp wrappers support

WITH_LIBWRAP:BOOL=OFF

// Link PARTITION statically to the server

WITH_PARTITION_STORAGE_ENGINE:BOOL=ON

// Link PERFSCHEMA statically to the server

WITH_PERFSCHEMA_STORAGE_ENGINE:BOOL=ON

// Generate PIC objects

WITH_PIC:BOOL=OFF

// Use bundled readline

WITH_READLINE:BOOL=OFF

// Options are : no, bundled, yes (prefer os library if present otherwise use bundled), system (use os library)

WITH_SSL:STRING=no

// Compile MySQL with unit tests

WITH_UNIT_TESTS:BOOL=ON

// Valgrind instrumentation

WITH_VALGRIND:BOOL=OFF

// Use bundled zlib

WITH_ZLIB:STRING=bundled

[[email protected] mysql-5.5.38]#

2.1 执行编译.

cmake . -DCMAKE_INSTALL_PREFIX:PATH=/usr/local/mysql \

-DMYSQL_DATADIR:PATH=/data/mysql \

-DSYSCONFDIR=/etc \

-DWITH_INNOBASE_STORAGE_ENGINE:BOOL=ON \

-DWITH_ARCHIVE_STORAGE_ENGINE:BOOL=On \

-DWITH_BLACKHOLE_STORAGE_ENGINE:BOOL=On \

-DWITH_EXTRA_CHARSETS:STRING=all \

-DWITH_READLINE:BOOL=On \

-DWITH_SSL:STRING=system \

-DWITH_ZLIB=system \

-DWITH_LIBWRAP:BOOL=OFF \

-DENABLED_PROFILING:BOOL=ON \

-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \

-DDEFAULT_CHARSET=utf8 \

-DDEFAULT_COLLATION=utf8_general_ci

make && make install

2.2初始化mysql.

chown -R root:mysql /usr/local/mysql

cd /usr/local/mysql

scripts/mysql_install_db --user=mysql --datadir=/data/mysql

cp support-files/my-medium.cnf /etc/my.cnf

cp support-files/mysql.server /etc/init.d/mysqld

echo "export PATH=$PATH:/usr/local/mysql/bin;" >/etc/profile.d/mysql.sh

. /etc/profile.d/mysql.sh

vi /etc/my.cnf,在[mysqld]中增加datadir=/data/mysql 与innodb_file_per_table =on

bin/mysqld_safe  --user=mysql &

chkconfig --add mysqld

chkconfig mysqld on

service mysqld status

2.3验证并删除匿名用户.

[[email protected] mysql]# service mysqld status

MySQL running (1581)[确定]

[[email protected] mysql]# mysql

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 1

Server version: 5.5.38-log 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.01 sec)

mysql> select user,host,password from mysql.user;

+------+-----------+----------+

| user | host      | password |

+------+-----------+----------+

| root | localhost |          |

| root | mytest2   |          |

| root | 127.0.0.1 |          |

| root | ::1       |          |

|      | localhost |          |

|      | mytest2   |          |

+------+-----------+----------+

6 rows in set (0.01 sec)

mysql> drop user ‘‘@‘localhost‘;

Query OK, 0 rows affected (0.00 sec)

mysql> drop user ‘‘@mytest2;

Query OK, 0 rows affected (0.00 sec)

mysql> drop user ‘root‘@‘::1‘;

Query OK, 0 rows affected (0.00 sec)

mysql> select user,host,password from mysql.user;

+------+-----------+----------+

| user | host      | password |

+------+-----------+----------+

| root | localhost |          |

| root | mytest2   |          |

| root | 127.0.0.1 |          |

+------+-----------+----------+

3 rows in set (0.00 sec)

至此mysql安装完成.

mysql默认配置文件查找路径顺序如下:

/etc/my.cnf

/etc/mysql/my.cnf

$MYSQL_HOME/my.cnf

~/.my.cnf

启动mysql时指定的--default_extra路径.

异常的处理方法: 错误:‘SSL_OP_NO_COMPRESSION’ 未声明 (在此函数内第一次使用)

1.下载较新的openssl.

2.编译安装

./config shared zlib-dynamic --prefix=/usr/local/openssl

make && make install

3.配置

mv /usr/bin/openssl /usr/bin/openssl_bak

mv /usr/lib/include/openssl /usr/lib/include/openssl_bak

mv /usr/lib/libssl.so  /usr/lib/libssl.so_bak

mv /usr/lib64/libssl.so /usr/lib64/libssl.so_bak

ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl

ln -s /usr/local/openssl/include/openssl   /usr/include/openssl

ln -s /usr/local/openssl/lib/libssl.so /usr/lib/libssl.so

ln -s /usr/local/openssl/lib/libssl.so /usr/lib64/libssl.so

echo "/usr/local/openssl/lib" >>/etc/ld.so.conf

ldconfig -v

4.配置完成后,重新编译mysql即可.

mysql数据库的编译安装

时间: 2024-11-20 08:57:54

mysql数据库的编译安装的相关文章

MySQL源码编译安装(CentOS-6.6+MySQL-5.6)

MySQL源码编译安装(CentOS-6.6+MySQL-5.6) 部署环境 操作系统:CentOS-6.6-x86_64-bin-DVD1.iso MySQL版本:mysql-5.6.26.tar.gz 操作用户:root 系统IP:192.168.1.205 主机名:edu-mysql-01 配置:4核.4G内存 一.服务器配置: 1.配置网络 # vi /etc/sysconfig/network-scripts/ifcfg-eth0 DEVICE=eth0 BOOTPROTO=stati

linux下nginx,mysql,php(lnmp)编译安装

关闭SELINUX vi /etc/selinux/config #SELINUX=enforcing #注释掉 #SELINUXTYPE=targeted #注释掉 SELINUX=disabled #增加 :wq!  #保存退出 setenforce 0 #使配置立即生效 mysql 5.5.28安装 安装路径:/usr/local/mysql数据库路径:/usr/local/mysql/data/ mysql从5.5版本开始,不再使用./configure编译,而是使用cmake编译器,具

Mysql数据库介绍、安装和配置文件

Mysql数据库介绍.安装和配置文件 MySQL数据库介绍 mysql是开源关系型数据库,遵循GPL协议. mysql的特点是性能卓越且服务稳定,开源,无版本限制,成本低,单进程多线程,多用户,基于C/S(客户端/服务端)架构,安全可靠,插入式存储引擎. mysql的另个版本为MariaDB,MariaDB是单进程,多线程的,提供了诸多扩展和新特性,提供了较多测试组件并且同样开源. mysql系统结构 一.逻辑模块组成 MySQL 可以看成是二层架构. 第一层我们通常叫做SQL Layer,在M

Cent OS 6.5 LAMP(Apache+php+mysql+Xcache) 编译安装

详细编译安装LAMP环境 安装OS及软件版本 OS:Cent OS 6.5 apache:httpd-2.4.10.tar.gz php:php-5.4.31.tar.bz2 mysql:mysql-5.6.19.tar.gz Xcache:xcache-3.1.0.tar.gz 一.安装前准备 修改主机名    [[email protected] ~]#sed -i 's/HOSTNAME=localhost.localdomain/HOSTNAME=linux.lamp.com/g' /e

Mysql数据库的通用安装方法

安装方式简介 Mysql数据库也时不时的用过一段时间,具体使用的功能都比较浅显,没有具体深入学习.最近一段在公司部署iNeedle系统时经常避免不了要安装apache和Mysql数据库.一般Mysql安装有这么几种方式:源码安装.repos安装(apt-get或yum)方式.二进制包安装(tar包).在部署iNeedle系统时候安装mysql都是采用apt-get或yum的方式来进行安装:由于对mysql的版本没有特别的要求,所以一般都采用这种方式就能满足需求.yum源的安装方式虽然速度比较快(

mysql 5.5编译安装

实现:1. 安装cmake依赖包 # yum -y install ntp vim-enhanced gcc gcc-c++ flex bison autoconf automake bzip2-devel ncurses-devel zlib-devel libjpeg-devel libpng-devel libtiff-devel freetype-devel libXpm-devel gettext-devel  pam-devel libtool libtool-ltdl openss

高可用架构篇 MySQL源码编译安装(CentOS-6.6+MySQL-5.6)

具体操作参考视频教程:http://www.roncoo.com/course/view/85d6008fe77c4199b0cdd2885eaeee53 部署环境 操作系统:CentOS-6.6-x86_64-bin-DVD1.iso MySQL版本:mysql-5.6.26.tar.gz 操作用户:root 系统IP:192.168.1.205 主机名:edu-mysql-01 配置:4核.4G内存 一.服务器配置: 1.配置网络 # vi /etc/sysconfig/network-sc

lnmp环境安装(3)-mysql源码编译安装

一.概述 MySQL是一个跨平台的开源关系型数据库管理系统,目前隶属于Oracle公司.MySQL被广泛地应用在Internet上的中小型网站中.由于其体积小.速度快.总体拥有成本低,尤其是开放源码这一特点,许多中小型网站为了降低网站总体拥有成本而选择了MySQL作为网站数据库. 本节采用mysql-5.6.16的源码进行mysql的安装. mysql的源码级别的安装要基于一个工具cmake来进行安装.CMake是一个跨平台的安装(编译)工具,可以用简单的语句来描述所有平台的安装(编译过程) 以

Nginx、MySQL、PHP 编译安装

RHEL 7.0 编译安装Nginx1.6.0+MySQL5.6.19+PHP5.5.14运行环境 准备篇: RHEL 7.0系统安装配置图解教程 http://www.jb51.net/os/192932.html 一.使用系统镜像文件配置本地yum源 1.使用WinSCP.exe等工具上传系统镜像文件rhel-server-7.0-x86_64-dvd.iso到/usr/local/src目录 2.使用Putty.exe工具远程连接到RHEL服务器 3.挂载系统镜像文件 mkdir /med