Linux使用原始碼來安裝MySQL 5.7
Linux使用原始碼安裝MySQL
有兩種方法來使用原始碼安裝MySQL:
.使用一種標準的MySQL原始碼安裝。標準的可用原始碼檔案被壓縮成tar檔案,zip檔案或RPM包。檔名的格式為mysql-version.tar.gz,mysql-version.zip或mysql-version.rpm。其中version是版本號比例如5.7.25。釋出的原始碼檔名與預先編譯好的二進位制檔名是有區別的,原始碼檔名通常不包含平臺名,而二進位制檔名包含平臺名,例如pc-linux-i686或winx64。
.使用MySQL開發樹。如何構建開發樹將在使用開發原始碼樹來安裝MySQL中進行介紹。
使用原始碼安裝MySQL作業系統所要滿足的條件
使用原始碼來安裝MySQL需要幾個開發工具。無論您使用的是標準的原始碼分發版還是開發原始碼樹,都需要這些工具中的一部分。是否需要其它工具依賴於你的安裝方法。
為了使用原始碼來安裝MySQL,不管使用何種安裝方法下面的要求必須要滿足:
.CMake,用來在所有平臺上構建框架,可以從來下載CMake。
.一個好的make程式,雖然一些平臺有它們自己的make實現,但強烈建議使用GNU make 3.75或更高版本。它可能已經存在於你的系統中了gmake。可以從下載GNU make。
.ANSI C++編譯器。可以對force_unsupported_compiler的描述。
.為了構建MySQL需要Boost C++庫(但不使用它)。Boost 1.59.0必須被安裝。為了獲得Boost與它的安裝指令,可以訪問網址。在Boost安裝後,當呼叫CMake時透過使用WITH_BOOST選項來告訴構建系統在哪裡定位Boost檔案。
shell>cmake . -DWITH_BOOST=/usr/local/boost_1_59_0
根據實際情況來調整路徑。
.ncurses庫 https://www.gnu.org/software/ncurses/ncurses.html
.足夠的空閒記憶體。當編譯很大的原始檔時如果遇到了"internal compiler error"錯誤,那麼可能是因為你沒有足夠的記憶體。如果在一個虛擬機器上進行編譯,嘗試增加記憶體分配。
.如果你希望執行測試指令碼那麼就需要安裝perl。大多數像Unix的系統已經包含了perl。在windows上可以使用ActiveState Perl。
為了使用標準的原始碼釋出版本來安裝MySQL,需要以下一種工具來解壓釋出的原始碼檔案:
.對於一個.tar.gz的壓縮tar檔案,GNU gunzip可以用來解壓tar用來unpack。如果你的tar程式支援z選項,它可以用來解壓與 unpack檔案。GNU tar眾所周知是有效的。一些作業系統提供的標準tar不能對MySQL釋出版本的長檔名進行unpack操作。你應該安裝GUN tar或者可能的話,使用預安裝版本的GNU tar。常用的有gnutar,gtar,tar或者自由軟體目錄,比如/usr/sfw/bin或/usr/local/bin。GNU tar可以從進行下載。
.對於一個.zip歸檔檔案,winzip或另外的工具可以讀取.zip檔案。
.對於一個.rpm的RPM包,rpmbuild程式用來對構建的釋出版本進行unpack操作。
為了使用開發原始碼樹來安裝MySQL,需要安裝以下額外的工具:
.需要Git版本控制系統來獲得開發原始碼。提供了指令在不同平臺上下載與安裝Git。MySQL官方組織已經於2014年9月加入了GitHub。
.bison 2.1或更高版本,可以從網址進行下載(1版本不再支援),儘可能的使用最新版本,如果你遇到了問題,那麼升級到最新的版本,而不是回退到更早的版本。
bison可以從網址進行下載,對於Windows平臺可以從網址進行下載。在Windows平臺上,bison的預設目錄是C:\Program Files\GnuWin32目錄。有一些工具可以在查詢bison會失敗,因為在目錄名中存在空隔。同樣,Visual Studio如果在路徑中存在空隔可能會出現hang住。為了解決這種問題的出現,可以將bison安裝到C:\GnuWin32目錄。
.在Solaris平臺上,除了bison之外m4必須被安裝。m4可以從網址下載。
注意在安裝任何程式之後,需要修改你的PATH環境變數來包含定位程式的目錄。
原始碼安裝MySQL的佈局
預設情況下,當使用原始碼編譯後安裝MySQL,安裝操作會將檔案安裝在/usr/local/mysql目錄中。這與使用二進位制檔案安裝的安裝目錄是一樣的。
使用標準原始碼安裝MySQL
1.安裝所需要的工具包
[root@localhost ~]# yum -y install gcc* gcc-c++ ncurses* ncurses-devel* cmake* bison* libgcrypt* perl* make* ....... 已安裝: gcc-gnat.x86_64 0:4.8.5-36.0.1.el7 gcc-objc.x86_64 0:4.8.5-36.0.1.el7 gcc-objc++.x86_64 0:4.8.5-36.0.1.el7 libgcrypt-devel.x86_64 0:1.5.3-14.el7 ncurses-devel.x86_64 0:5.9-14.20130511.el7_4 ncurses-term.noarch 0:5.9-14.20130511.el7_4 perl-Algorithm-Diff.noarch 0:1.1902-17.el7 perl-App-cpanminus.noarch 0:1.6922-2.el7 perl-Archive-Extract.noarch 1:0.68-3.el7 perl-Archive-Zip.noarch 0:1.30-11.el7 perl-Authen-SASL.noarch 0:2.15-10.el7 perl-B-Lint.noarch 0:1.17-3.el7 perl-Bit-Vector.x86_64 0:7.3-3.el7 perl-CGI.noarch 0:3.63-4.el7 perl-CGI-Session.noarch 0:4.35-16.el7 perl-CPAN.noarch 0:1.9800-293.el7 perl-CPAN-Meta.noarch 0:2.120921-5.el7 perl-CPAN-Meta-Requirements.noarch 0:2.122-7.el7 perl-CPAN-Meta-YAML.noarch 0:0.008-14.el7 perl-CPANPLUS.noarch 0:0.91.38-4.el7 perl-CPANPLUS-Dist-Build.noarch 0:0.70-3.el7 perl-Carp-Clan.noarch 0:6.04-10.el7 perl-Class-ISA.noarch 0:0.36-1010.el7 perl-Class-Load.noarch 0:0.20-3.el7 perl-Class-Singleton.noarch 0:1.4-14.el7 perl-Convert-ASN1.noarch 0:0.26-4.el7 perl-DBD-MySQL.x86_64 0:4.023-6.0.1.el7 perl-DBD-Pg.x86_64 0:2.19.3-4.el7 perl-DBIx-Simple.noarch 0:1.35-7.el7 perl-Data-OptList.noarch 0:0.107-9.el7 perl-Date-Calc.noarch 0:6.3-14.el7 perl-Date-Manip.noarch 0:6.41-2.el7 perl-DateTime.x86_64 2:1.04-6.el7 perl-DateTime-Format-DateParse.noarch 0:0.05-5.el7 perl-DateTime-Locale.noarch 0:0.45-6.el7 perl-DateTime-TimeZone.noarch 0:1.70-1.el7 perl-Devel-Symdump.noarch 1:2.10-2.el7 perl-Digest-SHA1.x86_64 0:2.13-9.el7 perl-Env.noarch 0:1.04-2.el7 perl-ExtUtils-CBuilder.noarch 1:0.28.2.6-293.el7 perl-ExtUtils-Embed.noarch 0:1.30-293.el7 perl-FCGI.x86_64 1:0.74-8.el7 perl-File-CheckTree.noarch 0:4.42-3.el7 perl-File-Fetch.noarch 0:0.42-2.el7 perl-Font-AFM.noarch 0:1.20-13.el7 perl-FreezeThaw.noarch 0:0.5001-10.el7 perl-GD.x86_64 0:2.49-3.el7 perl-GSSAPI.x86_64 0:0.28-9.el7 perl-HTML-Format.noarch 0:2.10-7.el7 perl-HTML-Tree.noarch 1:5.03-2.el7 perl-IO-stringy.noarch 0:2.110-22.el7 perl-IPC-Cmd.noarch 1:0.80-4.el7 perl-JSON.noarch 0:2.59-2.el7 perl-JSON-PP.noarch 0:2.27202-2.el7 perl-LDAP.noarch 1:0.56-6.el7 perl-LWP-Protocol-https.noarch 0:6.04-4.el7 perl-List-MoreUtils.x86_64 0:0.33-9.el7 perl-Locale-Codes.noarch 0:3.26-2.el7 perl-Locale-Maketext.noarch 0:1.23-3.el7 perl-Locale-Maketext-Simple.noarch 1:0.21-293.el7 perl-Log-Message.noarch 1:0.08-3.el7 perl-Log-Message-Simple.noarch 0:0.10-2.el7 perl-Module-Build.noarch 2:0.40.05-2.el7 perl-Module-CoreList.noarch 1:2.76.02-293.el7 perl-Module-Implementation.noarch 0:0.06-6.el7 perl-Module-Load.noarch 1:0.24-3.el7 perl-Module-Load-Conditional.noarch 0:0.54-3.el7 perl-Module-Loaded.noarch 1:0.08-293.el7 perl-Module-Metadata.noarch 0:1.000018-2.el7 perl-Module-Pluggable.noarch 1:4.8-3.el7 perl-Module-Runtime.noarch 0:0.013-4.el7 perl-Module-Signature.noarch 0:0.73-2.el7 perl-Mozilla-CA.noarch 0:20130114-5.el7 perl-Newt.x86_64 0:1.08-36.el7 perl-Object-Accessor.noarch 1:0.42-293.el7 perl-PAR-Dist.noarch 0:0.49-2.el7 perl-Package-DeprecationManager.noarch 0:0.13-7.el7 perl-Package-Stash.noarch 0:0.34-2.el7 perl-Package-Stash-XS.x86_64 0:0.26-3.el7 perl-Params-Check.noarch 1:0.38-2.el7 perl-Params-Util.x86_64 0:1.07-6.el7 perl-Params-Validate.x86_64 0:1.08-4.el7 perl-Parse-CPAN-Meta.noarch 1:1.4404-5.el7 perl-Perl-OSType.noarch 0:1.003-3.el7 perl-Perl4-CoreLibs.noarch 0:0.003-7.el7 perl-Pod-Checker.noarch 0:1.60-2.el7 perl-Pod-Coverage.noarch 0:0.23-3.el7 perl-Pod-LaTeX.noarch 0:0.61-2.el7 perl-Pod-Parser.noarch 0:1.61-2.el7 perl-Pod-Plainer.noarch 0:1.03-4.el7 perl-SGMLSpm.noarch 0:1.03ii-31.el7 perl-SNMP_Session.noarch 0:1.13-5.el7 perl-String-ShellQuote.noarch 0:1.04-10.el7 perl-Sub-Install.noarch 0:0.926-6.el7 perl-Sys-CPU.x86_64 0:0.54-4.el7 perl-Sys-Guestfs.x86_64 1:1.38.2-12.0.1.el7 perl-Sys-MemInfo.x86_64 0:0.91-7.el7 perl-Sys-Virt.x86_64 0:4.5.0-2.el7 perl-Term-UI.noarch 0:0.36-2.el7 perl-Test-Pod.noarch 0:1.48-3.el7 perl-Test-Pod-Coverage.noarch 0:1.08-21.el7 perl-Test-Simple.noarch 0:0.98-243.el7 perl-Text-Diff.noarch 0:1.41-5.el7 perl-Text-Soundex.x86_64 0:3.04-4.el7 perl-Text-Unidecode.noarch 0:0.04-20.el7 perl-Time-Piece.x86_64 0:1.20.1-293.el7 perl-Try-Tiny.noarch 0:0.12-2.el7 perl-Version-Requirements.noarch 0:0.101022-244.el7 perl-XML-Dumper.noarch 0:0.81-17.el7 perl-XML-Filter-BufferText.noarch 0:1.01-17.el7 perl-XML-Grove.noarch 0:0.46alpha-52.el7 perl-XML-SAX-Writer.noarch 0:0.53-4.el7 perl-XML-Twig.noarch 0:3.44-2.el7 perl-XML-Writer.noarch 0:0.623-3.el7 perl-XML-XPath.noarch 0:1.13-22.el7 perl-YAML.noarch 0:0.84-5.el7 perl-YAML-Tiny.noarch 0:1.51-6.el7 perl-autodie.noarch 0:2.16-2.el7 perl-core.x86_64 0:5.16.3-293.el7 perl-gettext.x86_64 0:1.05-28.el7 perl-homedir.noarch 0:1.008010-4.el7 perl-libintl.x86_64 0:1.20-12.el7 perl-libxml-perl.noarch 0:0.08-19.el7 perl-local-lib.noarch 0:1.008010-4.el7 perltidy.noarch 0:20121207-3.el7 作為依賴被安裝: glusterfs-cli.x86_64 0:3.12.2-18.el7 glusterfs-client-xlators.x86_64 0:3.12.2-18.el7 libgnat.x86_64 0:4.8.5-36.0.1.el7 libgnat-devel.x86_64 0:4.8.5-36.0.1.el7 libgpg-error-devel.x86_64 0:1.12-3.el7 libobjc.x86_64 0:4.8.5-36.0.1.el7 libvirt-bash-completion.x86_64 0:4.5.0-10.el7 libvirt-daemon-driver-storage-core.x86_64 0:4.5.0-10.el7 libvirt-daemon-driver-storage-disk.x86_64 0:4.5.0-10.el7 libvirt-daemon-driver-storage-gluster.x86_64 0:4.5.0-10.el7 libvirt-daemon-driver-storage-iscsi.x86_64 0:4.5.0-10.el7 libvirt-daemon-driver-storage-logical.x86_64 0:4.5.0-10.el7 libvirt-daemon-driver-storage-mpath.x86_64 0:4.5.0-10.el7 libvirt-daemon-driver-storage-rbd.x86_64 0:4.5.0-10.el7 libvirt-daemon-driver-storage-scsi.x86_64 0:4.5.0-10.el7 libvirt-libs.x86_64 0:4.5.0-10.el7 openjade.x86_64 0:1.3.2-45.el7 opensp.x86_64 0:1.5.2-19.el7 pcp-selinux.x86_64 0:4.1.0-4.el7 postgresql-libs.x86_64 0:9.2.24-1.el7_5 squashfs-tools.x86_64 0:4.3-0.21.gitaae0aff4.el7 更新完畢: bison.x86_64 0:3.0.4-2.el7 gcc.x86_64 0:4.8.5-36.0.1.el7 gcc-c++.x86_64 0:4.8.5-36.0.1.el7 gcc-gfortran.x86_64 0:4.8.5-36.0.1.el7 libgcrypt.x86_64 0:1.5.3-14.el7 make.x86_64 1:3.82-23.el7 ncurses.x86_64 0:5.9-14.20130511.el7_4 ncurses-base.noarch 0:5.9-14.20130511.el7_4 ncurses-libs.x86_64 0:5.9-14.20130511.el7_4 perl.x86_64 4:5.16.3-293.el7 perl-Digest-SHA.x86_64 1:5.85-4.el7 perl-ExtUtils-Install.noarch 0:1.58-293.el7 perl-ExtUtils-ParseXS.noarch 1:3.18-3.el7 perl-Getopt-Long.noarch 0:2.40-3.el7 perl-Git.noarch 0:1.8.3.1-19.el7 perl-HTTP-Daemon.noarch 0:6.01-8.el7 perl-IO-Socket-IP.noarch 0:0.21-5.el7 perl-IO-Socket-SSL.noarch 0:1.94-7.el7 perl-IO-Zlib.noarch 1:1.10-293.el7 perl-Net-DNS.x86_64 0:0.72-6.el7 perl-Net-SSLeay.x86_64 0:1.55-6.el7 perl-PCP-PMDA.x86_64 0:4.1.0-4.el7 perl-Package-Constants.noarch 1:0.02-293.el7 perl-Pod-Escapes.noarch 1:1.04-293.el7 perl-Socket.x86_64 0:2.010-4.el7 perl-Test-Harness.noarch 0:3.28-3.el7 perl-devel.x86_64 4:5.16.3-293.el7 perl-hivex.x86_64 0:1.3.10-6.9.el7 perl-libs.x86_64 4:5.16.3-293.el7 perl-macros.x86_64 4:5.16.3-293.el7 perl-version.x86_64 3:0.99.07-3.el7 作為依賴被升級: cpp.x86_64 0:4.8.5-36.0.1.el7 git.x86_64 0:1.8.3.1-19.el7 glusterfs.x86_64 0:3.12.2-18.el7 glusterfs-api.x86_64 0:3.12.2-18.el7 glusterfs-fuse.x86_64 0:3.12.2-18.el7 glusterfs-libs.x86_64 0:3.12.2-18.el7 glusterfs-rdma.x86_64 0:3.12.2-18.el7 hivex.x86_64 0:1.3.10-6.9.el7 libgcc.x86_64 0:4.8.5-36.0.1.el7 libgfortran.x86_64 0:4.8.5-36.0.1.el7 libgomp.x86_64 0:4.8.5-36.0.1.el7 libguestfs.x86_64 1:1.38.2-12.0.1.el7 libquadmath.x86_64 0:4.8.5-36.0.1.el7 libquadmath-devel.x86_64 0:4.8.5-36.0.1.el7 libstdc++.x86_64 0:4.8.5-36.0.1.el7 libstdc++-devel.x86_64 0:4.8.5-36.0.1.el7 libvirt.x86_64 0:4.5.0-10.el7 libvirt-client.x86_64 0:4.5.0-10.el7 libvirt-daemon.x86_64 0:4.5.0-10.el7 libvirt-daemon-config-network.x86_64 0:4.5.0-10.el7 libvirt-daemon-config-nwfilter.x86_64 0:4.5.0-10.el7 libvirt-daemon-driver-interface.x86_64 0:4.5.0-10.el7 libvirt-daemon-driver-lxc.x86_64 0:4.5.0-10.el7 libvirt-daemon-driver-network.x86_64 0:4.5.0-10.el7 libvirt-daemon-driver-nodedev.x86_64 0:4.5.0-10.el7 libvirt-daemon-driver-nwfilter.x86_64 0:4.5.0-10.el7 libvirt-daemon-driver-qemu.x86_64 0:4.5.0-10.el7 libvirt-daemon-driver-secret.x86_64 0:4.5.0-10.el7 libvirt-daemon-driver-storage.x86_64 0:4.5.0-10.el7 libvirt-daemon-kvm.x86_64 0:4.5.0-10.el7 openssl.x86_64 1:1.0.2k-16.0.1.el7 openssl-libs.x86_64 1:1.0.2k-16.0.1.el7 pcp.x86_64 0:4.1.0-4.el7 pcp-conf.x86_64 0:4.1.0-4.el7 pcp-libs.x86_64 0:4.1.0-4.el7 python-pcp.x86_64 0:4.1.0-4.el7 supermin5.x86_64 0:5.1.19-1.el7 完畢!
2.使用命令檢查是否安裝有MySQL Server包
[root@localhost ~]# rpm -qa | grep mysql [root@localhost ~]# rpm -aq | grep mysql mysql-community-libs-5.6.23-3.el7.x86_64 qt-mysql-4.8.5-8.0.1.el7.x86_64 akonadi-mysql-1.9.2-4.0.1.el7.x86_64 mysql-community-common-5.6.23-3.el7.x86_64 mysql-community-server-5.6.23-3.el7.x86_64 mysql-community-client-5.6.23-3.el7.x86_64
刪除操作有以下兩種
rpm -e mysql-libs //普通刪除模式
rpm -e --nodeps mysql-lib// 強力刪除模式,如果使用上面命令刪除時,提示有依賴的其它檔案,則用該命令可以對其進行強力刪除
[root@localhost ~]# rpm -e --nodeps mysql-community-libs [root@localhost ~]# rpm -e --nodeps akonadi-mysql [root@localhost ~]# rpm -e --nodeps mysql-community-common [root@localhost ~]# rpm -e --nodeps mysql-community-server [root@localhost ~]# rpm -e --nodeps mysql-community-client [root@localhost ~]# rpm -e --nodeps qt-mysql [root@localhost ~]# rpm -aq | grep mysql
3.下載原始碼檔案mysql-5.7.26.tar.gz並上傳到伺服器的/soft目錄中
[root@localhost soft]# ls -lrt 總用量 79960 -rw-r--r--. 1 root root 54056899 5月 30 16:36 mysql-5.7.26.tar.gz
4.下載boost包並上傳到伺服器的/soft目錄中
5. 建立mysql使用者與使用者組
[root@localhost /]# groupadd mysql [root@localhost /]# useradd -r -g mysql -s /bin/false mysql
因為使用者只用於所有權目的,而不是登入目的,useradd命令使用-r與-s /bin/false選項來建立一個使用者沒有登入伺服器主機的許可權。
6.建立並修改/mysqlsoft/mysql與/mysqldata/mysql目錄許可權
[root@localhost /]# mkdir -p /mysqlsoft/mysql [root@localhost /]# mkdir -p /mysqldata/mysql [root@localhost /]# chown -R mysql:mysql /mysqlsoft [root@localhost /]# chown -R mysql:mysql /mysqldata/mysql [root@localhost /]# chmod -R 775 /mysqlsoft/mysql [root@localhost /]# chmod -R 775 /mysqldata/mysql
7.解壓boost軟體包與MySQL原始碼包
[root@localhost soft]# unzip boost_1_59_0.zip [root@localhost soft]# ls -lrt 總用量 201556 drwx------. 8 root root 4096 8月 12 2015 boost_1_59_0 -rw-r--r--. 1 root root 54056899 5月 30 16:36 mysql-5.7.26.tar.gz -rw-r--r--. 1 root root 124506259 6月 13 21:07 boost_1_59_0.zip
將MySQL檔案解壓到/soft目錄下
[root@localhost soft]# tar zxvf mysql-5.7.26.tar.gz [root@localhost soft]# ls -lrt 總用量 201560 drwx------. 8 root root 4096 8月 12 2015 boost_1_59_0 drwxr-xr-x. 35 7161 31415 4096 4月 13 21:46 mysql-5.7.26 -rw-r--r--. 1 root root 54056899 5月 30 16:36 mysql-5.7.26.tar.gz -rw-r--r--. 1 root root 27816900 6月 10 11:32 docker-17.03.0-ce.tgz -rw-r--r--. 1 root root 124506259 6月 13 21:07 boost_1_59_0.zip 總用量 4 [root@localhost soft]# chown -R mysql:mysql mysql-5.7.26 [root@localhost soft]# chmod -R 775 mysql-5.7.26
8.預編譯MySQL
[root@localhost soft]# su - mysql 上一次登入:一 6月 17 12:21:54 CST 2019pts/0 上 -bash-4.2$ cd /soft/mysql-5.7.26/ -bash-4.2$ cmake . -DCMAKE_INSTALL_PREFIX=/mysqlsoft/mysql \ > -DMYSQL_DATADIR=/mysqldata/mysql \ > -DMYSQL_UNIX_ADDR=/mysqlsoft/mysql/mysql.sock \ > -DWITH_BOOST=../boost_1_59_0 \ > -DWITH_INNOBASE_STORAGE_ENGINE=1 \ > -DWITH_PARTITION_STORAGE_ENGINE=1 \ > -DWITH_FEDERATED_STORAGE_ENGINE=1 \ > -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \ > -DWITH_MYISAM_STORAGE_ENGINE=1 \ > -DENABLED_LOCAL_INFILE=1 \ > -DENABLE_DTRACE=0 \ > -DDEFAULT_CHARSET=utf8mb4 \ > -DDEFAULT_COLLATION=utf8mb4_general_ci \ > -DWITH_EMBEDDED_SERVER=1 .................... -- Found PkgConfig: /bin/pkg-config (found version "0.27.1") -- checking for module 'libtirpc' -- package 'libtirpc' not found -- Performing Test HAVE_STRUCT_SOCKADDR_SA_LEN -- Performing Test HAVE_STRUCT_SOCKADDR_SA_LEN - Failed -- Performing Test HAVE_STRUCT_IFREQ_IFR_NAME -- Performing Test HAVE_STRUCT_IFREQ_IFR_NAME - Success -- Performing Test HAVE_XDR_OPS_X_PUTINT32 -- Performing Test HAVE_XDR_OPS_X_PUTINT32 - Success -- Performing Test HAVE_XDR_OPS_X_GETINT32 -- Performing Test HAVE_XDR_OPS_X_GETINT32 - Success -- Performing Test HAVE___CONST -- Performing Test HAVE___CONST - Success -- Performing Test HAVE_RPC_INLINE_T -- Performing Test HAVE_RPC_INLINE_T - Failed -- Performing Test OLD_XDR -- Performing Test OLD_XDR - Failed -- Performing Test X_GETPOSTN_NOT_USE_CONST -- Performing Test X_GETPOSTN_NOT_USE_CONST - Success -- Performing Test HAS_INCOMPATIBLE_POINTER_TYPES -- Performing Test HAS_INCOMPATIBLE_POINTER_TYPES - Failed -- Performing Test X_PUTLONG_NOT_USE_CONST -- Performing Test X_PUTLONG_NOT_USE_CONST - Failed -- checking for module 'libtirpc' -- package 'libtirpc' not found -- RPC_INCLUDE_DIRS /usr/include -- Using Boost headers from /soft/boost_1_59_0 -- Performing Test CXX_HAVE_SIGN_COMPARE -- Performing Test CXX_HAVE_SIGN_COMPARE - Success -- Performing Test CXX_HAVE_UNUSED_VARIABLE -- Performing Test CXX_HAVE_UNUSED_VARIABLE - Success -- MYSQLX - Text log of protobuf messages enabled -- Performing Test HAVE_UNUSED_PARAMETER -- Performing Test HAVE_UNUSED_PARAMETER - Success -- Googletest was not found. gtest-based unit tests will be disabled. You can run cmake . -DENABLE_DOWNLOADS=1 to automatically download and build required components from source. -- If you are inside a firewall, you may need to use an https proxy: export https_proxy= -- Performing Test HAVE_MISLEADING_INDENTATION -- Performing Test HAVE_MISLEADING_INDENTATION - Failed -- executable target mysqld debug_target /soft/debug/sql/mysqld -- Library mysqlserver depends on OSLIBS -lpthread;m;rt;crypt;dl -- MERGE_CONVENIENCE_LIBRARIES TARGET mysqlserver -- MERGE_CONVENIENCE_LIBRARIES LIBS dbug;strings;regex;mysys;mysys_ssl;vio;zlib;yassl;taocrypt;crypt;dl;archive_embedded;blackhole_embedded;csv_embedded;federated_embedded;heap_embedded;innobase_embedded;lz4_lib;myisam_embedded;myisammrg_embedded;partition_embedded;ngram_parser_embedded;sql_embedded -- MERGE_CONVENIENCE_LIBRARIES MYLIBS dbug;strings;regex;mysys;mysys_ssl;vio;zlib;yassl;taocrypt;archive_embedded;blackhole_embedded;csv_embedded;federated_embedded;heap_embedded;innobase_embedded;lz4_lib;myisam_embedded;myisammrg_embedded;partition_embedded;ngram_parser_embedded;sql_embedded -- library target mysqlserver debug_target /soft/debug/archive_output_directory/libmysqld.a -- INSTALL mysqlclient.pc lib/pkgconfig -- Skipping deb packaging on unsupported platform . -- CMAKE_BUILD_TYPE: RelWithDebInfo -- COMPILE_DEFINITIONS: _GNU_SOURCE;_FILE_OFFSET_BITS=64;HAVE_CONFIG_H;HAVE_LIBEVENT2 -- CMAKE_C_FLAGS: -Wall -Wextra -Wformat-security -Wvla -Wwrite-strings -Wdeclaration-after-statement -- CMAKE_CXX_FLAGS: -Wall -Wextra -Wformat-security -Wvla -Woverloaded-virtual -Wno-unused-parameter -- CMAKE_C_LINK_FLAGS: -- CMAKE_CXX_LINK_FLAGS: -- CMAKE_C_FLAGS_RELWITHDEBINFO: -O3 -g -fabi-version=2 -fno-omit-frame-pointer -fno-strict-aliasing -DDBUG_OFF -- CMAKE_CXX_FLAGS_RELWITHDEBINFO: -O3 -g -fabi-version=2 -fno-omit-frame-pointer -fno-strict-aliasing -DDBUG_OFF -- Configuring done -- Generating done -- Build files have been written to: /soft/mysql-5.7.26
9.編譯原始碼,這時使用-j 6選項來使用6個程式同時進行編譯
-bash-4.2$ make -j 6 ......... Building CXX object sql/CMakeFiles/sql.dir/event_data_objects.cc.o Building CXX object sql/CMakeFiles/sql.dir/des_key_file.cc.o Building CXX object sql/CMakeFiles/sql.dir/event_db_repository.cc.o [ 97%] Building CXX object sql/CMakeFiles/sql.dir/event_parse_data.cc.o [ 97%] Building CXX object sql/CMakeFiles/sql.dir/event_queue.cc.o [ 97%] Building CXX object sql/CMakeFiles/sql.dir/event_scheduler.cc.o [ 97%] Building CXX object sql/CMakeFiles/sql.dir/events.cc.o [ 97%] Building CXX object sql/CMakeFiles/sql.dir/mf_iocache.cc.o [ 97%] Building CXX object sql/CMakeFiles/sql.dir/mysqld.cc.o [ 97%] Building CXX object sql/CMakeFiles/sql.dir/mysqld_thd_manager.cc.o [ 97%] Building CXX object sql/CMakeFiles/sql.dir/protocol_callback.cc.o [ 97%] Building CXX object sql/CMakeFiles/sql.dir/signal_handler.cc.o [ 98%] Building CXX object sql/CMakeFiles/sql.dir/sql_audit.cc.o [ 98%] Building CXX object sql/CMakeFiles/sql.dir/sql_client.cc.o [ 98%] Building CXX object sql/CMakeFiles/sql.dir/srv_session.cc.o [ 98%] Building CXX object sql/CMakeFiles/sql.dir/srv_session_info_service.cc.o [ 98%] Building CXX object sql/CMakeFiles/sql.dir/srv_session_service.cc.o [ 98%] Building CXX object sql/CMakeFiles/sql.dir/auth/sha2_password_common.cc.o [ 98%] Building CXX object sql/CMakeFiles/sql.dir/mysqld_daemon.cc.o Linking CXX static library ../archive_output_directory/libsql.a [ 98%] Built target sql Scanning dependencies of target mysqld Scanning dependencies of target pfs_connect_attr-t [ 99%] Building CXX object sql/CMakeFiles/mysqld.dir/main.cc.o Linking CXX executable mysqld [100%] [100%] [100%] Building CXX object storage/perfschema/unittest/CMakeFiles/pfs_connect_attr-t.dir/__/__/__/sql/sql_builtin.cc.o Building CXX object storage/perfschema/unittest/CMakeFiles/pfs_connect_attr-t.dir/pfs_connect_attr-t.cc.o Building C object storage/perfschema/unittest/CMakeFiles/pfs_connect_attr-t.dir/__/__/__/mysys/string.c.o Linking CXX executable pfs_connect_attr-t [100%] Built target mysqld [100%] Built target pfs_connect_attr-t
10.安裝
-bash-4.2$ make install ................. -- Installing: /mysqlsoft/mysql/mysql-test/./t/wl6661.test -- Installing: /mysqlsoft/mysql/mysql-test/./t/wl6711_heap_to_disk.test -- Installing: /mysqlsoft/mysql/mysql-test/./t/wl6978.test -- Installing: /mysqlsoft/mysql/mysql-test/./t/xa.test -- Installing: /mysqlsoft/mysql/mysql-test/./t/xa_debug.test -- Installing: /mysqlsoft/mysql/mysql-test/./t/xa_gtid-master.opt -- Installing: /mysqlsoft/mysql/mysql-test/./t/xa_gtid.test -- Installing: /mysqlsoft/mysql/mysql-test/./t/xa_prepared_binlog_off-master.opt -- Installing: /mysqlsoft/mysql/mysql-test/./t/xa_prepared_binlog_off.test -- Installing: /mysqlsoft/mysql/mysql-test/./t/xml.test -- Installing: /mysqlsoft/mysql/mysql-test/./valgrind.supp -- Installing: /mysqlsoft/mysql/mysql-test/./mtr -- Installing: /mysqlsoft/mysql/mysql-test/./mysql-test-run -- Installing: /mysqlsoft/mysql/mysql-test/./Makefile -- Installing: /mysqlsoft/mysql/mysql-test/./cmake_install.cmake -- Installing: /mysqlsoft/mysql/mysql-test/./CTestTestfile.cmake -- Installing: /mysqlsoft/mysql/./COPYING-test -- Installing: /mysqlsoft/mysql/./README-test -- Up-to-date: /mysqlsoft/mysql/mysql-test/mtr -- Up-to-date: /mysqlsoft/mysql/mysql-test/mysql-test-run -- Installing: /mysqlsoft/mysql/mysql-test/lib/My/SafeProcess/my_safe_process -- Up-to-date: /mysqlsoft/mysql/mysql-test/lib/My/SafeProcess/my_safe_process -- Installing: /mysqlsoft/mysql/mysql-test/lib/My/SafeProcess/Base.pm -- Installing: /mysqlsoft/mysql/support-files/mysqld_multi.server -- Installing: /mysqlsoft/mysql/support-files/mysql-log-rotate -- Installing: /mysqlsoft/mysql/support-files/magic -- Installing: /mysqlsoft/mysql/share/aclocal/mysql.m4 -- Installing: /mysqlsoft/mysql/support-files/mysql.server [root@localhost mysqlsoft]# chmod -R 775 mysql
11.配置mysql引數,只是設定幾個簡單的mysql執行引數
[root@localhost mysql]# vi /mysqlsoft/mysql/my.cnf [mysqld] basedir=/mysqlsoft/mysql datadir=/mysqldata/mysql bind-address=0.0.0.0 user=mysql port=3306 log-error=/mysqldata/mysql/mysql.err pid-file=/mysqldata/mysql/mysqld.pid socket = /mysqlsoft/mysql/mysql.sock character-set-server=utf8mb4 default-storage-engine=INNODB explicit_defaults_for_timestamp = true [root@localhost mysql]# cd bin [root@localhost bin]# ./mysqld --defaults-file=/mysqlsoft/mysql/my.cnf --initialize --basedir=/mysqlsoft/mysql --datadir=/mysqldata/mysql --user=mysql
檢視日誌資訊
[root@localhost mysql]# tail -f mysql.err 2019-06-17T06:28:34.137849Z 0 [Warning] InnoDB: New log files created, LSN=45790 2019-06-17T06:28:35.342112Z 0 [Warning] InnoDB: Creating foreign key constraint system tables. 2019-06-17T06:28:35.465187Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 2296e390-90c9-11e9-9a9f-005056a390e6. 2019-06-17T06:28:35.471829Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened. 2019-06-17T06:28:35.474533Z 1 [Note] A temporary password is generated for root@localhost: Ldp#HUPR(7hH
其中[Note] A temporary password is generated for root@localhost:後面跟的是mysql資料庫登入的臨時密碼,各人安裝生成的臨時密碼不一樣。可以看到到日誌檔案沒有報錯,而且有了臨時密碼,表示初始化成功。
12.如果想服務能夠部署自動支援安全連線,使用mysql_ssl_rsa_setup工具來建立預設SSL與RSA檔案
[root@localhost bin]# ./mysql_ssl_rsa_setup --datadir=/mysqldata/mysql Generating a 2048 bit RSA private key ...........................+++ .......+++ writing new private key to 'ca-key.pem' ----- Generating a 2048 bit RSA private key .......................................................................................................+++ ...................................................................................................................................................+++ writing new private key to 'server-key.pem' ----- Generating a 2048 bit RSA private key .....................................+++ ...........+++ writing new private key to 'client-key.pem' -----
13.啟動MySQL
[root@localhost bin]# ./mysqld_safe --user=mysql & [1] 19442 [root@localhost bin]# 2019-06-17T06:34:01.654203Z mysqld_safe Logging to '/mysqldata/mysql/mysql.err'. 2019-06-17T06:34:01.750954Z mysqld_safe Starting mysqld daemon with databases from /mysqldata/mysql
14.配置自動啟動MySQL
[root@localhost ~]# cp /mysqlsoft/mysql/support-files/mysql.server /etc/init.d/mysqld [root@localhost ~]# chmod 755 /etc/init.d/mysqld [root@localhost ~]# systemctl enable mysqld mysqld.service is not a native service, redirecting to /sbin/chkconfig. Executing /sbin/chkconfig mysqld on
14.配置環境變數
[root@localhost ~]# vi /etc/profile # /etc/profile # System wide environment and startup programs, for login setup # Functions and aliases go in /etc/bashrc # It's NOT a good idea to change this file unless you know what you # are doing. It's much better to create a custom.sh shell script in # /etc/profile.d/ to make custom changes to your environment, as this # will prevent the need for merging in future updates. export MYSQL_HOME=/mysqlsoft/mysql/ export PATH=$PATH:$MYSQL_HOME/bin
15.登入MySQL並修改root使用者密碼
-bash-4.2$ mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.7.26 Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '123456'; Query OK, 0 rows affected (0.00 sec)
到此使用原始碼來安裝MySQL就完成了。
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26015009/viewspace-2649373/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 基於Linux的MySQL5.7原始碼編譯安裝LinuxMySql原始碼編譯
- Linux下安裝MySQL 5.7LinuxMySql
- Linux 7 安裝Mysql 5.7LinuxMySql
- Mysql for Linux安裝配置之—— 原始碼安裝MySqlLinux原始碼
- linux離線安裝mysql5.7LinuxMySql
- mysql 原始碼安裝-5.7-17-19版本MySql原始碼
- Linux下安裝Nginx+PHP7.1+MySQL5.7LinuxNginxPHPMySql
- Docker 安裝 Mysql 5.7DockerMySql
- 基於Linux的MySQL5.7RPM包安裝LinuxMySql
- 在Oracle Linux 7.1中使用原始碼來安裝PostgreSQL 9.6OracleLinux原始碼SQL
- centos安裝mysql5.7CentOSMySql
- mysql5.7 安裝教程MySql
- CentOS 7 安裝 MySQL 5.7CentOSMySql
- CentOS 7 - 安裝MySQL 5.7CentOSMySql
- centos7安裝mysql5.7 使用yumCentOSMySql
- 連網安裝mysql與原始碼安裝mysqlMySql原始碼
- MySQL 5.7.28 原始碼安裝MySql原始碼
- linux 非root使用者原始碼安裝Linux原始碼
- Linux安裝MySQL(使用yum)LinuxMySql
- Linux下安裝使用MySQLLinuxMySql
- Windows安裝MySQL5.7教程WindowsMySql
- Ubuntu 18.04 安裝配置 MySQL 5.7UbuntuMySql
- Ubuntu 16.04 上安裝 MySQL 5.7UbuntuMySql
- MySQL:mysql5.7解壓版安裝與解除安裝MySql
- linux安裝python3(原始碼安裝)LinuxPython原始碼
- Mysql 5.7 免安裝版windows安裝完整教程MySqlWindows
- mysql5.5.20原始碼安裝MySql原始碼
- windows同時安裝 5.7 8.0 mysqlWindowsMySql
- mysql5.7安裝_centos7MySqlCentOS
- 如何在debain上安裝mysql 5.7AIMySql
- CentOS7.3 安裝 MySQL5.7CentOSMySql
- MySQL5.7綠色版安裝MySql
- CentOS7 安裝mysql5.7CentOSMySql
- macOS Mojave 降級安裝 MySQL 5.7MacMySql
- mysql5.7tar包的安裝MySql
- mysql5.7GeleraCluster安裝部署(二)MySql
- windows安裝及配置mysql5.7WindowsMySql
- ubuntu16 安裝mysql5.7UbuntuMySql