MySQL 安装(源码安装模式)

MySQL 安装(RPM安装模式)及目录结构

MySQL 安装(二进制安装模式)

MySQL 安装(源码安装模式)



本篇使用mysql源码来安装,稍微比较麻烦。

 CentOS release 5.11+ mysql-5.6.22


使用源码编译,需要下载一款工具cmake:

What’s Cmake?官方说明如下:

CMake is a family of tools designed tobuild, test and package software. CMake is used to control the software compilationprocess using simple platform and compiler independent configuration files.CMake generates native makefiles and workspaces that can be used in thecompiler environment of your choice.

Cmake官方下载地址:http://www.cmake.org/download/


本次测试安装的cmake版本:

Release Candidate(3.2.0-rc2)—Source distributions—Unix/Linux Source (has \n line feeds)—cmake-3.2.0-rc2.tar.gz


Cmake解压:

ll /usr/local/src/cmake-3.2.0-rc2.tar.gz

tar zxvfcmake-3.2.0-rc2.tar.gz

mv/usr/local/src/cmake-3.2.0-rc2 /usr/local/cmake


编译安装:

cd /usr/local/cmake/

./configure

技术分享

#configure完成后提示:now run gmake,接下来再执行gmake

gmake

make

make install


安装mysql,官方参考:Installing MySQL Using a Standard Source Distribution


先创建mysql用户及组:

groupadd mysql

useradd -r -g mysql mysql


mysql当前实例下载地址:(size 30M)

http://ftp.iij.ad.jp/pub/db/mysql/Downloads/MySQL-5.6/MySQL-5.6.22-1.linux_glibc2.5.src.rpm


解压rpm包:

mv MySQL-5.6.22-1.linux_glibc2.5.src.rpm /usr/local/src

rpm2cpioMySQL-5.6.22-1.linux_glibc2.5.src.rpm | cpio -div

技术分享

tar zxvf mysql-5.6.22.tar.gz

mv/usr/local/src/mysql-5.6.22 /usr/local/mysql


编译mysql:(5.5版本(含)以上使用cmake,5.1使用./configure

cd /usr/local/mysql

 

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

-DMYSQL_DATADIR=/usr/local/mysql/data\

-DMYSQL_TCP_PORT=3306 \

-DSYSCONFDIR=/etc \

-DEXTRA_CHARSETS=all \

-DDEFAULT_CHARSET=utf8 \

-DDEFAULT_COLLATION=utf8_general_ci\

-DENABLED_LOCAL_INFILE=1 \

-DWITH_INNOBASE_STORAGE_ENGINE=1\

-DWITH_ARCHIVE_STORAGE_ENGINE=1\

-DWITH_BLACKHOLE_STORAGE_ENGINE=1\

-DWITH_PERFSCHEMA_STORAGE_ENGINE=1

 

#以上配置参数更多参考:MySQL Source-Configuration Options

make

make install


设置根目录所有者:

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


复制服务和配置文件到系统配置文件中:

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

cp/usr/local/mysql/support-files/my-default.cnf /etc/my.cnf


编辑mysql配置文件添加以下参数:vi /etc/my.cnf

[mysqld]

basedir =/usr/local/mysql

datadir=/usr/local/mysql/data

port = 3306

server_id = 1


初始化数据库:

chmod 755/usr/local/mysql/scripts/mysql_install_db

/usr/local/mysql/scripts/mysql_install_db--user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data


设置开机启动mysqld服务:

chkconfig mysqld on


设置环境变量:vi/root/.bash_profile

#PATH=$PATH:$HOME/bin

PATH=$PATH:$HOME/bin:/usr/local/mysql/bin

技术分享

[root@localhost ~]# source/root/.bash_profile


启动mysqld服务:

chmod 755 /etc/init.d/mysqld

/etc/init.d/mysqld start

service mysqld restart



设置mysql密码及相关设置:

/usr/local/mysql/bin/mysql_secure_installation

 

完成!!成功登录!

技术分享



安装基本就完成了,先补点水分。


郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。