您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

编译安装mysql(Ubuntu10 64位)_MySQL

2025/11/4 16:54:17发布28次查看
ubuntu
bitscn.com选用较好的编译器和较好的编译器选项,这样应用可提高性能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) 
:
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
:
#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
:
#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编译安装过程
bitscn.com
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product