失眠网,内容丰富有趣,生活中的好帮手!
失眠网 > 源码编译mysql 5.5+ 安装过程全记录

源码编译mysql 5.5+ 安装过程全记录

时间:2020-02-16 21:48:18

相关推荐

源码编译mysql 5.5+ 安装过程全记录

前言:从MySQL5.5版本开始,mysql源码安装开始使用cmake了,编译安装跟以前的版本有点不一样了。

一,安装步骤:

1.安装前准备工作

a.下载mysql源代码包,到mysql下载页面选择MYSQL Community Serve Source Code 版本

注意:不要选择Linux-Generic版本,此版本为已经编译好的二进制版本

b.检查本机Linux是否已安装好make,bison,cmake,gcc-c++,ncurses,如果尚未安装,先安装以上包,安装方法如下:

注意:一般系统都会默认安装有make,gcc-c++.

1.安装make编译器

下载地址:/software/make/

[plain]view plaincopy

#tarzxvfmake-3.82.tar.gz

#cdmake-3.82

#./configure

#make

#makeinstall

也可用:yum install make.i686 安装此包

2.安装bison

下载地址:/software/bison/

[plain]view plaincopy

<spanstyle="font-size:13px;">#tarzxvfbison-2.5.tar.gz

#cdbison-2.5

#./configure

#make

#makeinstall</span>

也可用:yum install bison.i686 安装此包

3.安装gcc-c++

下载地址:/software/gcc

[plain]view plaincopy

#tarzxvfgcc-c++-4.4.4.tar.gz

#cdgcc-c++-4.4.4

#./configure

#make

#makeinstall

也可用:yum install gcc-c++.i686 安装此包

4.安装cmake

下载地址:/

[plain]view plaincopy

#tarzxvfcmake-2.8.4.tar.gz

#cdcmake-2.8.4

#./configure

#make

#makeinstall

也可用:yum install cmake.i686 安装此包

5.安装ncurses

下载地址:/software/ncurses/

[plain]view plaincopy

#tarzxvfncurses-5.8.tar.gz

#cdncurses-5.8

#./configure

#make

#makeinstall

也可用:yum install ncurses.i686 安装此包

2.添加mysql用户与组

[plain]view plaincopy

#groupaddmysql

#useradd-gmysql-s/sbin/nologin-Mmysql

3.mysql的源码编译

[plain]view plaincopy

#tarzxvfmysql-5.5.13.tar.gz

#cdmysql-5.5.13

#rmCMakeCache.txt

#cmake.-DCMAKE_INSTALL_PREFIX=/usr/local/mysql55/-DMYSQL_DATADIR=/usr/local/mysql55/data-DWITH_INNOBASE_STORAGE_ENGINE=1-DMYSQL_TCP_PORT=3306-DMYSQL_UNIX_ADDR=/usr/local/mysql55/data/mysql.sock-DMYSQL_USER=mysql-DWITH_DEBUG=0

#make

#makeinstall

4.编译完成后,安装数据库

[plain]view plaincopy

#cd/usr/local/mysql

#chown-Rmysql.

#chgrp-Rmysql.

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

#chown-Rroot.

#chown-Rmysql./data

某次安装完数据库完后,启动不了数据库,查看日志显示:Can"t open the mysql.plugin table...-06-01 00:52Can"t open the mysql.plugin table. Please run mysql_upgrade to create it.

解决方法:重新执行数据库安装过程,并带上

[html]view plaincopy

--basedir=/usr/local/mysql--datadir=/usr/local/mysql/data

于是搞定 5.下面的命令是可选的,将mysql的配置文件拷贝到/etc

cp support-files/my-f /etc/f如果原来的/etc目录下有f文件,则一定要用编译安装的f替换掉系统默认的my..cnf,否则会报如下错误:

[html]view plaincopy

/usr/local/mysql/bin/mysqld:Table"mysql.plugin"doesn"texist

12040623:57:45[ERROR]Can"topenthemysql.plugintable.Pleaserunmysql_upgradetocreateit.

12040623:57:45InnoDB:TheInnoDBmemoryheapisdisabled

12040623:57:45InnoDB:Mutexesandrw_locksuseGCCatomicbuiltins

12040623:57:45InnoDB:Compressedtablesusezlib1.2.3

12040623:57:45InnoDB:Initializingbufferpool,size=128.0M

12040623:57:45InnoDB:Completedinitializationofbufferpool

InnoDB:Thefirstspecifieddatafile./ibdata1didnotexist:

InnoDB:anewdatabasetobecreated!

12040623:57:45InnoDB:Settingfile./ibdata1sizeto10MB

InnoDB:Databasephysicallywritesthefilefull:wait...

12040623:57:45InnoDB:Logfile./ib_logfile0didnotexist:newtobecreated

InnoDB:Settinglogfile./ib_logfile0sizeto5MB

InnoDB:Databasephysicallywritesthefilefull:wait...

12040623:57:45InnoDB:Logfile./ib_logfile1didnotexist:newtobecreated

InnoDB:Settinglogfile./ib_logfile1sizeto5MB

InnoDB:Databasephysicallywritesthefilefull:wait...

InnoDB:Doublewritebuffernotfound:creatingnew

InnoDB:Doublewritebuffercreated

InnoDB:127rollbacksegment(s)active.

InnoDB:Creatingforeignkeyconstraintsystemtables

InnoDB:Foreignkeyconstraintsystemtablescreated

12040623:57:46InnoDB:Waitingforthebackgroundthreadstostart

12040623:57:47InnoDB:1.1.8started;logsequencenumber0

12040623:57:47[ERROR]/usr/local/mysql/bin/mysqld:Can"tcreate/writetofile"/var/run/mysqld/mysqld.pid"(Errcode:2)

12040623:57:47[ERROR]Can"tstartserver:can"tcreatePIDfile:Nosuchfileordirectory

12040623:57:47mysqld_safemysqldfrompidfile/var/run/mysqld/mysqld.pidended

6.启动mysql:

[plain]view plaincopy

#bin/mysqld_safe--user=mysql&

##启动mysql,看是否成功

#netstat-tnl|grep3306

#或者

#ps-aux|grep"mysql"

可选步骤:设置root 密码:

/usr/local/mysql/bin/mysqladmin -u root password "new-password"

/usr/local/mysql/bin/mysqladmin -u root -h localhost.localdomain password "new-password"

此步骤需要在数据库启动之后才能执行成功

7.配置自启动

[plain]view plaincopy

#cpsupport-files/mysql.server/etc/init.d/mysqld

#chmod+x/etc/init.d/mysqld

#chkconfig–addmysqld

或者这样启动:

[plain]view plaincopy

##将mysql的启动服务添加到系统服务中

#cpsupport-files/mysql.server/etc/init.d/mysql.server

##现在可以使用下面的命令启动mysql

#servicemysql.serverstart

##停止mysql服务

#servicemysql.serverstop

##重启mysql服务

#servicemysql.serverrestart

8

为了方便,将mysql 的bin目录加到PATH中export PATH=/usr/local/mysql/bin:$PATH

附:

关于重新编译问题:

Dealing with Problems Compiling MySQL

The solution to many problems involves reconfiguring. If you do reconfigure, take note of the following:

IfCMakeis run after it has previously been run,it may use information that was gathered during its previousinvocation. This information is stored inCMakeCache.txt. WhenCMakestarts up, it looks for that file and reads its contents if it exists,on the assumption that the information is still correct. Thatassumption is invalid when you reconfigure.

Each time you runCMake, you must runmakeagain to recompile. However, you may want to remove old object filesfrom previous builds first because they were compiled using differentconfiguration options.

To prevent old object files or configuration information from being used, run these commands on Unix before re-runningCMake:

shell> make cleanshell> rm CMakeCache.txt

如果觉得《源码编译mysql 5.5+ 安装过程全记录》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。