CentOS8部署LNMP環(huán)境之編譯安裝mysql8.0.29的教程詳解
一、前提
由于我安裝了幾次,我就不再講述報(bào)錯(cuò)了,有點(diǎn)打腦殼?。。√崆鞍严嚓P(guān)依賴和報(bào)錯(cuò)就地解決。
1、所需源碼包
mysql-8.0.19.tar.gz boost_1_70_0.tar.gz //安裝mysql-8所需要的boost版本 rpcsvc-proto-1.4.tar.gz //后面出錯(cuò)所需要的源碼包 mysql-8.0.19下載地址:http://mirrors.sohu.com/mysql/ boost_1_70_0下載地址:https://dl.bintray.com/boostorg/release/1.70.0/source/ rpcsvc-proto-1.4下載地址:https://github.com/thkukuk/rpcsvc-proto/releases/download/v1.4/
2、解決依賴
[14:41:21 root@wangzhike ~]#yum install -y cmake ncurses-devel
3、存放位置
軟件源代碼包存放位置:/usr/local/src
源碼包編譯安裝位置:/usr/local/軟件名字
二、編譯安裝mysql-8.0.19
1、上傳源碼包
boost_1_70_0.tar.gz mysql-8.0.19.tar.gz rpcsvc-proto-1.4.tar.gz

2、解決rpcsvc-proto-1.4
1)、解壓
[17:05:14 root@wangzhike software]#tar -zxf rpcsvc-proto-1.4.tar.gz -C /usr/local/src/
2)、一步安裝
[17:09:48 root@wangzhike rpcsvc-proto-1.4]#./configure && make && make install
3、解決boost_1_70_0
[17:13:48 root@wangzhike~]# mkdir -p /usr/local/boost [17:14:05 root@wangzhike~]# cd /usr/local/src [17:15:02 root@wangzhike src]#cp /software/boost_1_70_0.tar.gz /usr/local/boost/ [17:26:22 root@wangzhike boost]#tar xf boost_1_70_0.tar.gz ////只上傳到/usr/local/src/存放目錄,解壓到當(dāng)前boost目錄
4、創(chuàng)建mysql用戶及組
[17:27:46 root@wangzhike ~]#groupadd mysql [17:28:10 root@wangzhike ~]#useradd -g mysql mysql -s /bin/false ####創(chuàng)建用戶mysql并加入到mysql組,不允許mysql用戶直接登錄系統(tǒng) [17:28:11 root@wangzhike ~]#mkdir -p /data/mysql ####創(chuàng)建MySQL數(shù)據(jù)庫(kù)存放目錄 [17:29:13 root@wangzhike ~]#chown -R mysql:mysql /data/mysql ####設(shè)置MySQL數(shù)據(jù)庫(kù)存放目錄權(quán)限 [17:29:31 root@wangzhike ~]#mkdir -p /usr/local/mysql ####創(chuàng)建MySQL安裝目錄
5、安裝mysql-8.0.19
1)、解壓
[17:43:24 root@wangzhike software]#tar -zxf mysql-8.0.19.tar.gz -C /usr/local/src/ [17:43:47 root@wangzhike software]#cd /usr/local/src/ [17:43:53 root@wangzhike src]#cd mysql-8.0.19/
2)、安裝
[17:47:01 root@wangzhike mysql-8.0.19]#cmake . \ -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \ -DINSTALL_DATADIR=/data/mysql -DMYSQL_USER=mysql \ -DMYSQL_UNIX_ADDR=/tmp/mysqld.sock -DDEFAULT_CHARSET=utf8 \ -DDEFAULT_COLLATION=utf8_general_ci \ -DWITH_INNOBASE_STORAGE_ENGINE=1 \ -DWITH_EMBEDDED_SERVER=1 \ -DFORCE_INSOURCE_BUILD=1 \ -DWITH_MYISAM_STORAGE_ENGINE=1 \ -DENABLED_LOCAL_INFILE=1 \ -DEXTRA_CHARSETS=all \ -DWITH_BOOST=/usr/local/boost
若出現(xiàn)以下則沒毛病
CMake Warning: Manually-specified variables were not used by the
project:EXTRA_CHARSETS INSTALL_DATADIR MYSQL_USER WITH_EMBEDDED_SERVER– Build files have been written to: /usr/local/src/mysql-8.0.19
若出現(xiàn)以下關(guān)于rpc.h的錯(cuò)誤
Could not find rpc/rpc.h in /usr/include or /usr/include/tirpc
解決方法:
[17:45:47 root@wangzhike mysql-8.0.19]#find / -name rpc.h /usr/local/src/mysql-8.0.19/extra/libevent/include/event2/rpc.h /usr/local/src/mysql-8.0.19/plugin/group_replication/libmysqlgcs/src/bindings/xcom/xcom/windeps/sunrpc/rpc/rpc.h
####并將/usr/local/src/mysql-8.0.19/plugin/group_replication/libmysqlgcs/src/bindings/xcom/xcom/windeps/sunrpc/目錄下的rpc/rpc.h拷貝到/usr/include/
如下
[17:52:57 root@wangzhike mysql-8.0.19]#cp -a /usr/local/src/mysql-8.0.19/plugin/group_replication/libmysqlgcs/src/bindings/xcom/xcom/windeps/sunrpc/rpc /usr/include/
3)、make && install
[17:55:20 root@wangzhike mysql-8.0.19]#make -j 3 && install
//過程超長(zhǎng)且內(nèi)存不足的會(huì)報(bào)錯(cuò)
等待等待等待
若報(bào)以下錯(cuò)則表示內(nèi)存不足需要?jiǎng)?chuàng)建分區(qū)
+: fatal error: Killed signal terminated program cc1plus compilation terminated. make[2]: *** [sql/CMakeFiles/sql_gis.dir/build.make:154: sql/CMakeFiles/sql_gis.dir/gis/distance_functor.cc.o] Error 1 make[2]: *** Waiting for unfinished jobs.... make[1]: *** [CMakeFiles/Makefile2:11144: sql/CMakeFiles/sql_gis.dir/all] Error 2 make: *** [Makefile:163: all] Error 2
創(chuàng)建分區(qū):
[19:58:37 root@wangzhike mysql-8.0.19]#dd if=/dev/zero of=/swapfile bs=1k count=2048000 2048000+0 records in 2048000+0 records out 2097152000 bytes (2.1 GB, 2.0 GiB) copied, 6.07651 s, 345 MB/s ####獲取要增加的2G的SWAP文件塊 [20:10:02 root@wangzhike mysql-8.0.19]#mkswap /swapfile mkswap: /swapfile: insecure permissions 0644, 0600 suggested. Setting up swapspace version 1, size = 2 GiB (2097147904 bytes) no label, UUID=18a4bbb3-75d1-411b-ac0c-c87c63547509 ####創(chuàng)建SWAP文件 [20:10:07 root@wangzhike mysql-8.0.19]#swapon /swapfile swapon: /swapfile: insecure permissions 0644, 0600 suggested. ####激活SWAP文件 [20:10:12 root@wangzhike mysql-8.0.19]#swapon -s Filename Type Size Used Priority /dev/sda2 partition 2144252 137300 -2 /swapfile file 2047996 0 -3 #####查看SWAP信息是否正確 [20:10:19 root@wangzhike mysql-8.0.19]#echo "/var/swapfile swap swap defaults 0 0" >> /etc/fstab ####添加到fstab文件中讓系統(tǒng)引導(dǎo)時(shí)自動(dòng)啟動(dòng)
在重新執(zhí)行make -j 3 && make install ,出現(xiàn)以下畫面則沒有報(bào)錯(cuò)
```bash -- Installing: /usr/local/mysql/man/man1/comp_err.1 -- Installing: /usr/local/mysql/man/man1/ibd2sdi.1 -- Installing: /usr/local/mysql/man/man1/innochecksum.1 -- Installing: /usr/local/mysql/man/man1/lz4_decompress.1 -- Installing: /usr/local/mysql/man/man1/my_print_defaults.1 -- Installing: /usr/local/mysql/man/man1/myisam_ftdump.1 -- Installing: /usr/local/mysql/man/man1/myisamchk.1 -- Installing: /usr/local/mysql/man/man1/myisamlog.1 -- Installing: /usr/local/mysql/man/man1/myisampack.1 -- Installing: /usr/local/mysql/man/man1/mysql.1 -- Installing: /usr/local/mysql/man/man1/mysql.server.1 -- Installing: /usr/local/mysql/man/man1/mysql_config.1 -- Installing: /usr/local/mysql/man/man1/mysql_config_editor.1 -- Installing: /usr/local/mysql/man/man1/mysql_secure_installation.1 -- Installing: /usr/local/mysql/man/man1/mysql_ssl_rsa_setup.1 -- Installing: /usr/local/mysql/man/man1/mysql_tzinfo_to_sql.1 -- Installing: /usr/local/mysql/man/man1/mysql_upgrade.1 -- Installing: /usr/local/mysql/man/man1/mysqladmin.1 -- Installing: /usr/local/mysql/man/man1/mysqlbinlog.1 -- Installing: /usr/local/mysql/man/man1/mysqlcheck.1 -- Installing: /usr/local/mysql/man/man1/mysqld_multi.1 -- Installing: /usr/local/mysql/man/man1/mysqld_safe.1 -- Installing: /usr/local/mysql/man/man1/mysqldump.1 -- Installing: /usr/local/mysql/man/man1/mysqldumpslow.1 -- Installing: /usr/local/mysql/man/man1/mysqlimport.1 -- Installing: /usr/local/mysql/man/man1/mysqlman.1 -- Installing: /usr/local/mysql/man/man1/mysqlpump.1 -- Installing: /usr/local/mysql/man/man1/mysqlshow.1 -- Installing: /usr/local/mysql/man/man1/mysqlslap.1 -- Installing: /usr/local/mysql/man/man1/perror.1 -- Installing: /usr/local/mysql/man/man1/zlib_decompress.1 -- Installing: /usr/local/mysql/man/man8/mysqld.8 -- Installing: /usr/local/mysql/man/man1/mysqlrouter.1 -- Installing: /usr/local/mysql/man/man1/mysqlrouter_passwd.1 -- Installing: /usr/local/mysql/man/man1/mysqlrouter_plugin_info.1
三、初始化mysql數(shù)據(jù)庫(kù)
1、修改mysql目錄權(quán)限
[20:37:59 root@wangzhike mysql-8.0.19]#chown -R mysql:mysql /usr/local/mysql [20:42:07 root@wangzhike mysql-8.0.19]#chmod -R 755 /usr/local/mysql
2、初始化mysql
[20:45:07 root@wangzhike ~]#cd /usr/local/mysql/ [20:46:43 root@wangzhike mysql]#./bin/mysqld --initialize --user=mysql --datadir=/usr/local/mysql/data --character-set-server=utf8 2020-04-14T12:47:13.718724Z 0 [System] [MY-013169] [Server] /usr/local/mysql/bin/mysqld (mysqld 8.0.19) initializing of server in progress as process 9893 2020-04-14T12:47:13.719367Z 0 [Warning] [MY-013242] [Server] --character-set-server: 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. 2020-04-14T12:47:14.855541Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: rUG-.8kdw<1f ####生成mysql系統(tǒng)數(shù)據(jù)庫(kù)。
3、修改配置文件
mysql 8.0.x默認(rèn)沒有配置文件,我們自己創(chuàng)建一個(gè)。
[20:49:41 root@wangzhike mysql]#vi /usr/local/mysql/my.cnf 添加以下內(nèi)容: [client] port=3306 socket=/tmp/mysql.sock [mysqld] port=3306 user = mysql socket=/tmp/mysql.sock tmpdir = /tmp key_buffer_size=16M max_allowed_packet=128M default_authentication_plugin=mysql_native_password open_files_limit = 60000 explicit_defaults_for_timestamp server-id = 1 character-set-server = utf8 federated max_connections = 1000 max_connect_errors = 100000 interactive_timeout = 86400 wait_timeout = 86400 sync_binlog=0 back_log=100 default-storage-engine = InnoDB log_slave_updates = 1 [mysqldump] quick [client] password="123456" [mysqld-8.0] sql_mode=TRADITIONAL [mysqladmin] force [mysqld] key_buffer_size=16M service mysqld restart
:wq!保存退出
注意,service mysqld restart 這一句一定寫上,默認(rèn)密碼為123456
其他操作
[20:53:05 root@wangzhike mysql]#ln -s /usr/local/mysql/my.cnf /etc/my.cnf #添加到/etc目錄的軟連接 [20:53:12 root@wangzhike mysql]#cd [20:53:13 root@wangzhike ~]#cp /usr/local/mysql/support-files/mysql.server /etc/rc.d/init.d/mysqld #把Mysql加入系統(tǒng)啟動(dòng) [20:53:21 root@wangzhike ~]#chmod 755 /etc/init.d/mysqld #增加執(zhí)行權(quán)限 [20:53:28 root@wangzhike ~]#chkconfig mysqld on #加入開機(jī)啟動(dòng)
4、編輯文件
[20:53:39 root@wangzhike ~]#vi /etc/rc.d/init.d/mysqld ####找到basedir=并修改為/usr/local/mysql ####找到datadir=并修改為/data/mysql basedir=/usr/local/mysql #MySQL程序安裝路徑 datadir=/data/mysql #MySQl數(shù)據(jù)庫(kù)存放目錄
5、開機(jī)啟動(dòng)成功
[20:54:32 root@wangzhike ~]#service mysqld start Starting MySQL.Logging to '/data/mysql/wangzhike.err'. . SUCCESS! #啟動(dòng)成功
6、添加變量
[20:54:44 root@wangzhike ~]#vi /etc/profile 在最后一行添加export PATH=$PATH:/usr/local/mysql/bin [20:55:37 root@wangzhike ~]#source /etc/profile #使配置立刻生效
7、添加軟連接
[20:55:44 root@wangzhike ~]#ln -s /usr/local/mysql/lib/mysql /usr/lib/mysql [20:55:57 root@wangzhike ~]#ln -s /usr/local/mysql/include/mysql /usr/include/mysql ####以上為把myslq的庫(kù)文件鏈接到系統(tǒng)默認(rèn)的位置 [20:56:02 root@wangzhike ~]#mkdir /var/lib/mysql [20:56:14 root@wangzhike ~]#ln -s /tmp/mysql.sock /var/lib/mysql/mysql.sock
8、啟動(dòng)mysql
[21:40:14 root@wangzhike ~]#mysql -uroot -p123456 Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 9 Server version: 8.0.19 Source distribution Copyright (c) 2000, 2020, 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>
則表示登陸成功。
總結(jié)
到此這篇關(guān)于CentOS8部署LNMP環(huán)境之編譯安裝mysql-8.0.29的文章就介紹到這了,更多相關(guān)CentOS8部署LNMP環(huán)境之編譯安裝mysql-8.0.29內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
基于Debian的linux系統(tǒng)軟件安裝命令詳解 (推薦)
這篇文章主要介紹了基于Debian的linux系統(tǒng)軟件安裝命令,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值 ,需要的朋友可以參考下2020-03-03
淺談ubuntu 使用securecrt vi編輯出現(xiàn)的問題
下面小編就為大家?guī)硪黄獪\談ubuntu 使用securecrt vi編輯出現(xiàn)的問題。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2017-01-01
解決VScode配置遠(yuǎn)程調(diào)試Linux程序的問題
這篇文章主要介紹了VScode配置遠(yuǎn)程調(diào)試Linux程序及問題解決辦法,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-08-08
linux環(huán)境openssl、openssh升級(jí)流程
該文章詳細(xì)介紹了在Ubuntu 22.04系統(tǒng)上升級(jí)OpenSSL和OpenSSH的方法,首先,升級(jí)OpenSSL的步驟包括下載最新版本、安裝編譯環(huán)境、備份和安裝、驗(yàn)證等,然后,升級(jí)OpenSSH的步驟包括下載最新版本、安裝相關(guān)依賴、解壓和編譯安裝、查看版本、備份替換文件、重啟服務(wù)等2025-03-03
centos7下搭建ZooKeeper3.4中間件常用命令小結(jié)
Zookeeper 作為一個(gè)分布式的服務(wù)框架,主要用來解決分布式集群中應(yīng)用系統(tǒng)的一致性問題,它能提供基于類似于文件系統(tǒng)的目錄節(jié)點(diǎn)樹方式的數(shù)據(jù)存儲(chǔ)。這篇文章主要介紹了centos7下搭建ZooKeeper3.4中間件常用命令小結(jié),需要的朋友可以參考下2019-07-07
Vim如何使用相對(duì)行號(hào)實(shí)現(xiàn)一切操作詳解
在使用用Vim時(shí)時(shí)常會(huì)遇到像復(fù)制多行或者想快速向下/向上移動(dòng)多行時(shí)而不知道行數(shù)的情況, 今天發(fā)現(xiàn)一個(gè)Vim對(duì)此有幫助的特性: 相對(duì)行號(hào),下面這篇文章主要給大家介紹了關(guān)于Vim如何使用相對(duì)行號(hào)實(shí)現(xiàn)一切操作的相關(guān)資料,需要的朋友可以參考下。2017-11-11
Apache Rewrite實(shí)現(xiàn)URL的301跳轉(zhuǎn)和域名跳轉(zhuǎn)
Rewirte主要的功能就是實(shí)現(xiàn)URL的跳轉(zhuǎn),它的正則表達(dá)式是基于Perl語(yǔ)言。可基于服務(wù)器級(jí)的(httpd.conf)和目錄級(jí)的 (.htaccess)兩種方式2012-05-05
詳解如何在Linux(CentOS)下重置MySQL根(Root)密碼
本篇文章主要介紹了詳解如何在Linux(CentOS)下重置MySQL根(Root)密碼,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下。2017-03-03

