编译安装mysql(Ubuntu10 64位)

时间:2022-09-07 18:38:09

选用较好的编译器和较好的编译器选项,这样应用可提高性能10-30%,这个对大多数程序都非常重要

Mysql的编译,不同的版本具体的配置方式是有差别的

旧版的配置形式参考

这个形式主要是使用configure,具体参考

http://www.cnblogs.com/hemhem/archive/2011/03/14/2087481.html

http://blog.csdn.net/bing19880122/article/details/5830650

http://flyingdutchman.iteye.com/blog/1901149

MySQL cMake 新老参数对比及 cMake 配置及安装方法详解 http://waynerqiu.com/7/153.html

新版Cmake形式的配置

http://www.cmake.org/

http://www.cnblogs.com/2018/p/3091616.html

mysql配置

http://dev.mysql.com/doc/refman/5.6/en/source-configuration-options.html

http://dev.mysql.com/doc/refman/5.6/en/environment-variables.html

环境变量和CMAKE配置结合可以进行配置

如下是一个实例

#CMAKE_BUILD_TYPE Debug:-g Release:-O2 RelWithDebInfo:-O2 -g MinSizeRel:-Os

#WITH_EMBEDDED_SERVER  Whether to build the libmysqld embedded server library.

#WITH_PARTITION_STORAGE_ENGINE 表分区

#-DWITH_ASAN=1 \ #must gcc > 4.5 参考4.8.2

#DENABLE_DOWNLOADS google MOCK test

cmake . \

-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \

-DCMAKE_BUILD_TYPE=Release \

-DSYSCONFDIR=/etc \

-DINSTALL_SBINDIR=/usr/local/mysql/bin \

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

-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \

-DENABLED_LOCAL_INFILE=1 \

-DMYSQL_TCP_PORT=3306 \

-DDEFAULT_CHARSET=utf8 \

-DDEFAULT_COLLATION=utf8_general_ci \

-DWITH_EMBEDDED_SERVER=0 \

-DWITH_MYISAM_STORAGE_ENGINE=1 \

-DWITH_INNOBASE_STORAGE_ENGINE=1 \

-DWITH_PARTITION_STORAGE_ENGINE=1 \

-DWITH_ARCHIVE_STORAGE_ENGINE=0 \

-DWITH_BLACKHOLE_STORAGE_ENGINE=0 \

-DWITH_MEMORY_STORAGE_ENGINE=0 \

-DWITH_PERFSCHEMA_STORAGE_ENGINE=0 \

-DWITH_EXTRA_CHARSETS=none \

-DWITH_DEBUG=0 \

# -DWITH_ASAN=1 \

# -DENABLE_DOWNLOADS=0 \

#end of cmake

注意-DWITH_ASAN=1这个选项需要GCC的版本在4.5以上,而Ubuntu10上默认的GCC是4.4

GCC编译升级过程

http://ftp.tsukuba.wide.ad.jp/software/gcc/releases/gcc-4.8.2/gcc-4.8.2.tar.gz 从这下载GCC

使用如下的脚本可以进行升级

#!/bin/bash

# gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5.1)

:<<EOF

ftp://gcc.gnu.org/pub/gcc/infrastructure/

GNU Multiple Precision Library (GMP) version 4.3.2 (or later)

MPFR Library version 2.4.2 (or later)

MPC Library version 0.8.1 (or later)

EOF

gccver=4.8.2

gmpver=4.3.2

mpfrver=2.4.2

mpcver=0.8.1

# where you put the downloaded source packages

pkgdir=.

# where you will build gcc

rootdir=gcc-${gccver}

# where you want to install gcc

prefix=/opt/gcc-${gccver}

# the languages you want gcc to support

langs=c,c++

#0 unpack file

:<<EOF

#Create a new directory on a disk with plenty of space and unpack the sources there:

mkdir -p ${rootdir}

tar xzf ${pkgdir}/gcc-${gccver}.tar.gz

tar xjf ${pkgdir}/gmp-${gmpver}.tar.bz2

tar xjf ${pkgdir}/mpfr-${mpfrver}.tar.bz2

tar xzf ${pkgdir}/mpc-${mpcver}.tar.gz

#Next, move the prerequisite sources into the gcc source directory:

mv gmp-${gmpver}   ${rootdir}/gmp

mv mpfr-${mpfrver} ${rootdir}/mpfr

mv mpc-${mpcver}   ${rootdir}/mpc

EOF

#两种方式的编译和安装

#1.1 build on source  dir

pushd ${rootdir}

#make clean

#默认的gcc支持32/64的双编译 gcc.gnu.org/wiki/FAQ#gnu_stubs-32.h  glibc-devel-32bit 或 --disable-multilib

./configure --prefix=${prefix} --enable-languages=${langs} --disable-multilib

make

make install

popd

#1.2 build on other dir

:<<EOF

#Now create a build directory and change to it

mkdir -p objdir

cd objdir

#Now configure gcc:

mkdir -p ${prefix}

../${rootdir}/configure --prefix=${prefix} --enable-languages=${langs} --disable-multilib

#configure --prefix=/opt/gcc-4.8.2 --enable-languages=c,c++

#Now build gcc:

make

#Finally, install gcc:

make install

#fixincludes 目录没有拷贝的问题,估计是--disable-multilib

cd ..

EOF

###代码+编译文件 2.6G

#2 更改当前的默认 #具体可检索"更改Ubuntu gcc、g++默认编译器版本"

#修改默认gcc和g++为4.4的版本

sudo update-alternatives --remove-all gcc

sudo update-alternatives --remove-all g++

sudo update-alternatives --install /usr/bin/gcc gcc /opt/gcc-4.8.2/bin/gcc 40

sudo update-alternatives --install /usr/bin/g++ g++ /opt/gcc-4.8.2/bin/g++ 40

#配置默认的gcc和g++

sudo update-alternatives --config gcc

sudo update-alternatives --config g++

#3 系统的C++库覆盖

rm -f /usr/lib/libstdc++*

cp -f /opt/gcc-4.8.2/lib64/libstdc++.so.6.0.18 /usr/lib/.

cp -f /opt/gcc-4.8.2/lib64/libstdc++.so.6 /usr/lib/.

注意其中的--disable-multilib这个选项需要加上,因此默认的gcc是可以在64为平台上编译出32,64两种程序,因此编译版的gcc升级时就需要32位的头文件,如果没有安装的话,这个是无法编译的。

当然也有一些简化的方式,需要联网升级,如下的这个说明

http://www.qtcn.org/bbs/apps.php?q=diary&a=detail&did=1456&uid=139371

编译安装

此时就可以加上 -DWITH_ASAN=1 \ 进行编译了

注意:为了提高性能,我们只需要编译需要的功能即可

成功后的安装,就非常简单了,类似如下的脚本过程

make install

#sudo cp -f my.cnf /etc/my.cnf

#sudo chmod 0444 /etc/my.cnf

sudo sh -c 'groupadd mysql'

sudo sh -c 'useradd -r -g mysql mysql'

sudo chown -R mysql /usr/local/mysql/data

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

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

/usr/local/mysql/support-files/mysql.server start

login="/usr/local/mysql/bin/mysql -uroot -D mysql -e"

pass="/usr/local/mysql/bin/mysql -uroot -p123456 -D mysql -e"

${login} "update mysql.user set password=PASSWORD('123456') where user='root';"

${login} "flush privileges;"

详细的资料和脚本参考  http://pan.baidu.com/s/1Cc7cr

Gcc版本切换的脚本

由于新版的gcc的支持了C++11标准,默认要求差别较大,如果现有的工程需要低的版本的话,可以使用如下的形式对系统的gcc进行自动切换

#!/bin/bash

if [ $# = 1 ] ; then

#4.4 目前的Ubuntu10都是gcc 4.4

#修改默认gcc和g++

sudo update-alternatives --remove-all gcc

sudo update-alternatives --remove-all g++

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.4 40

sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.4 40

#配置默认的gcc和g++

sudo update-alternatives --config gcc

sudo update-alternatives --config g++

#系统的C++库覆盖 gcc 4.4

# rm -f /usr/lib/libstdc++*

# cp -f gcc4.4/libstdc++.so.6.0.13 /usr/lib/.

# ln -s /usr/lib/libstdc++.so.6.0.13 /usr/lib/libstdc++.so.6

else

#4.8

#gcc-4.8.2.tar.gz 安装到/opt

if [ -d /opt/gcc-4.8.2 ]; then

echo "gcc 4.8.2 installed"

else

tar xzf gcc-4.8.2.tar.gz -C /opt

fi

#修改默认gcc和g++

sudo update-alternatives --remove-all gcc

sudo update-alternatives --remove-all g++

sudo update-alternatives --install /usr/bin/gcc gcc /opt/gcc-4.8.2/bin/gcc 40

sudo update-alternatives --install /usr/bin/g++ g++ /opt/gcc-4.8.2/bin/g++ 40

#配置默认的gcc和g++

sudo update-alternatives --config gcc

sudo update-alternatives --config g++

#系统的C++库覆盖

# rm -f /usr/lib/libstdc++*

# cp -f /opt/gcc-4.8.2/lib64/libstdc++.so.6.0.18 /usr/lib/.

# cp -f /opt/gcc-4.8.2/lib64/libstdc++.so.6 /usr/lib/.

fi

#libstdc++.so.6 经试验选用高的libstdc++.so.6.0.18版本可以运行,具体都我们的应用有没有问题待验证

gcc -v

参考资料

这里有如上的相关资料和内容 http://pan.baidu.com/s/1Cc7cr

http://www.cnblogs.com/2018/p/3482263.html

http://www.cnblogs.com/2018/p/3464638.html

这两篇已经介绍了clang的安装和编译c++库的过程,下面会再讲讲mysql的clang编译安装过程

编译安装mysql(Ubuntu10 64位)的更多相关文章

  1. clang LLVM 介绍和安装(Ubuntu10 64位&rpar;

    http://www.csdn.net/article/2013-11-27/2817632 的对Stanley B.Lippman采访提到clang的一些优点,以前程序员杂志也写过,为了提高系统的性 ...

  2. clang编译mysql(Ubuntu10 64位&rpar;

    编译安装mysql(Ubuntu10 64位) http://www.cnblogs.com/2018/p/3482259.html 这个介绍了gcc形式编译安装mysql 那我们使用clang进行编 ...

  3. CentOS Linux下编译安装MySQL

    本文参考张宴的Nginx 0.8.x + PHP 5.2.13(FastCGI)搭建胜过Apache十倍的Web服务器(第6版)[原创]完成.所有操作命令都在CentOS 6.4 64位操作系统下实践 ...

  4. 源码编译安装 MySQL 5&period;5&period;x 实践

    1.安装cmakeMySQL从5.5版本开始,通过./configure进行编译配置方式已经被取消,取而代之的是cmake工具.因此,我们首先要在系统中源码编译安装cmake工具. # wget ht ...

  5. CentOS 编译安装 mysql

    1.前期准备 1.1 环境说明: 操作系统: CentOS release 6.4 (Final) [查看命令 cat /etc/redhat-release ] mysql : mysql-5.6. ...

  6. Linux CentOS6&period;5下编译安装MySQL 5&period;6&period;16【给力详细教程】

    一.编译安装MySQL前的准备工作 安装编译源码所需的工具和库 yum install gcc gcc-c++ ncurses-devel perl 安装cmake,从http://www.cmake ...

  7. Linux编译安装Mysql步骤

    一. Centos 用 wget 下载需要的软件,保存到目录/home/zwl/MySql/下 wget http://dev.mysql.com/get/Downloads/MySQL-5.5/my ...

  8. CentOS下编译安装MySQL 5&period;6&period;21

    一.编译安装MySQL前的准备工作 安装编译源码所需的工具和库 yum install gcc gcc-c++ ncurses-devel perl 安装cmake:http://www.cnblog ...

  9. win7硬盘安装Ubuntu12&period;04 64位时显示Error 15: File not found&period;

    安装Ubuntu12.04 -64位时,用EasyBCD建好引导文件重启电脑后出现如下错误: Error 15: File not found 原因一个是安装文件所在盘符不对,另一个是文件名.Ubun ...

  10. 【排障】编译安装Mysql并使用自启动脚本mysqld后报错

    本文用于记录在某次个人实验搭建DZ论坛,在编译安装部署mysql环节时出的错到最终排除错误的过程, 前面采用DZ官网所采用的编译安装mysql的过程就省去,主要从报错处开始讲述. (题外话,经此一役后 ...

随机推荐

  1. 根据地图上的两个点各自的x&comma;y坐标,计算出2点之间的直线距离。显示为公里、米

    /** * calc_map_distance() , 根据地图上的两个点各自的x,y坐标,计算出2点之间的直线距离 * @param array $point_1 第1个点的x,y坐标 array( ...

  2. iOS网络加载图片缓存策略之ASIDownloadCache缓存优化

    iOS网络加载图片缓存策略之ASIDownloadCache缓存优化   在我们实际工程中,很多情况需要从网络上加载图片,然后将图片在imageview中显示出来,但每次都要从网络上请求,会严重影响用 ...

  3. LeetCode&colon; Binary Tree Level Order Traversal &amp&semi;&amp&semi; Binary Tree Zigzag Level Order Traversal

    Title: Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to ...

  4. Hdu1095

    #include <stdio.h> int main() { int a,b; while(scanf("%d %d",&a,&b)!=EOF){ p ...

  5. 作为Qt 合作伙伴的V-Play,比大家都领先了一步 planet&period;qt&period;io

    今天发布博客,将Flappy Bird和其它的小游戏移植到Respberry PI了 http://planet.qt.io/ planet.qt.io 的repo: https://coderevi ...

  6. Swift - 使用UI Dynamics给UIKit组件添加移动吸附行为

    UI Dynamics是UIKit的一个新组成部分,它向iOS中的视图提供了与物理学有关的功能和动画.可以让你向视图中引入力和物理属性,可以让你的视图弹跳,舞动,受重力影响等等. 下面通过样例,演示使 ...

  7. jenkins、ant、selenium、testng搭建自动化测试框架

    如果在你的理解中自动化测试就是在eclipse里面讲webdriver的包引入,然后写一些测试脚本,这就是你所说的自动化测试,其实这个还不能算是真正的自动化测试,你见过每次需要运行的时候还需要打开ec ...

  8. redis 梳理笔记&lpar;二&rpar;

    一.redis 分布式 redis+keepalived (虚ip漂移) redis 100秒平均写入并发  3.6w (写入与keepalived监控程序无关) .redis 数据库内存已占有80% ...

  9. 工具资源系列之给虚拟机装个windows

    前面我们介绍了如何在 mac 宿主机安装 VMware 虚拟机软件,本节我们将继续介绍如何给虚拟机安装镜像,切换不同的操作系统. VMware 软件是容器,镜像是内核,这里的镜像指的是操作系统. 下载 ...

  10. 通过泛型来简化findViewById

    我们一般写findViewById都要加个强制转换,感觉很麻烦,现在你可以在你的BaseActivity中写入如下方法: @SuppressWarnings(“unchecked”) public f ...