mysql5.5源码安装_mysql5.5源码安装

本文提供了一份详细的 MySQL 5.5 版本从源码安装到配置运行的步骤指南,包括安装前的准备、源码包的编译安装、数据库初始化及系统服务设置等内容。

1、准备工作

groupadd mysql

useradd -r -g mysql mysql

mkdir /usr/local/mysql/        #创建mysql安装目录

mkdir /data/mysql               #创建数据存放目录

chown mysql:mysql -R /data/mysql

yum install -y gcc gcc-c++ libtool autoconf automake imake libxml2-devel expat-devel ncurses-devel cmake bison

wget  http://mirrors.sohu.com/mysql/MySQL-5.5/mysql-5.5.43.tar.gz

2、解压源码包,编译安装

tar -zxvf mysql-5.5.43.tar.gz

cd mysql-5.5.43              #进入解压后mysql目录

cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_DATADIR=/data/mysql/ -DMYSQL_USER=mysql -DMYSQL_TCP_PORT=3306

make && make install              #编译通过过,安装

3、初始化MySQL

cp support-files/my-medium.cnf /etc/my.cnf          #复制配置文件

cp support-files/mysql.server /etc/init.d/mysqld    #复制启动脚本

chmod 755 /etc/init.d/mysqld

cd /usr/local/mysql      #进入安装目录

chown -R mysql.mysql . # 授权

./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/data/mysql  #初始化数据库

/etc/init.d/mysqld start                                           #启动数据库

4、MySQL配置

chkconfig --add mysqld                                 #添加系统服务

chkconfig mysqld on                                     #添加开机启动

export PATH=$PATH:/usr/local/mysql/bin    #添加环境变量

echo ‘PATH=$PATH:/usr/local/mysql/bin‘ >> /etc/profile

service mysqld start/stop

本文出自 “linux---基础篇” 博客,请务必保留此出处http://perin.blog.51cto.com/10410663/1671385

mysql5.5源码安装

标签:local   mysql

本条技术文章来源于互联网,如果无意侵犯您的权益请点击此处反馈版权投诉

本文系统来源:http://perin.blog.51cto.com/10410663/1671385

# Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; version 2 of the License. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA CMAKE_MINIMUM_REQUIRED(VERSION 2.6) # Avoid warnings in higher versions if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" GREATER 2.6) CMAKE_POLICY(VERSION 2.8) endif() # We use PROPERTIES LINK_INTERFACE_LIBRARIES. See cmake --help-policy CMP0022 IF(CMAKE_VERSION VERSION_EQUAL "2.8.12" OR CMAKE_VERSION VERSION_GREATER "2.8.12") CMAKE_POLICY(SET CMP0022 OLD) ENDIF() # We use the LOCATION target property (CMP0026) # and get_target_property() for non-existent targets (CMP0045) # and INSTALL_NAME_DIR (CMP0042) IF(CMAKE_VERSION VERSION_EQUAL "3.0.0" OR CMAKE_VERSION VERSION_GREATER "3.0.0") CMAKE_POLICY(SET CMP0026 OLD) CMAKE_POLICY(SET CMP0045 OLD) CMAKE_POLICY(SET CMP0042 OLD) ENDIF() MESSAGE(STATUS "Running cmake version ${CMAKE_VERSION}") # Will set GIT_EXECUTABLE and GIT_FOUND FIND_PACKAGE(Git) SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake) # First, decide about build type (debug or release) # If custom compiler flags are set or cmake is invoked with -DCMAKE_BUILD_TYPE, # respect user wishes and do not (re)define CMAKE_BUILD_TYPE. If WITH_DEBUG{_FULL} # is given, set CMAKE_BUILD_TYPE = Debug. Otherwise, use Relwithdebinfo. IF(DEFINED CMAKE_BUILD_TYPE) SET(HAVE_CMAKE_BUILD_TYPE TRUE) ENDIF() SET(CUSTOM_C_FLAGS $ENV{CFLAGS}) OPTION(WITH_DEBUG "Use dbug/safemutex" OFF) # Distinguish between community and non-community builds, with the # default being a community build. This does not impact the feature # set that will be compiled in; it's merely provided as a hint to # custom packaging steps. OPTION(COMMUNITY_BUILD "Set to true if this is a community build" ON) # Use a default manufacturer if no manufacturer was identified. SET(MANUFACTURER_DOCSTRING "Set the entity that appears as the manufacturer of packages that support a manufacturer field.") IF(NOT DEFINED MANUFACTURER) SET(MANUFACTURER "Built from Source" CACHE STRING ${MANUFACTURER_DOCSTRING}) MARK_AS_ADVANCED(MANUFACTURER) ENDIF() # We choose to provide WITH_DEBUG as alias to standard CMAKE_BUILD_TYPE=Debug # which turns out to be not trivial, as this involves synchronization # between CMAKE_BUILD_TYPE and WITH_DEBUG. Besides, we have to deal with cases # where WITH_DEBUG is reset from ON to OFF and here we need to reset # CMAKE_BUILD_TYPE to either none or default RelWithDebInfo SET(BUILDTYPE_DOCSTRING "Choos
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符  | 博主筛选后可见
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值