通過源碼包方式實(shí)現(xiàn)MySQL-8.0安裝具體步驟

本篇文章給大家主要講的是關(guān)于通過源碼包方式實(shí)現(xiàn)MySQL-8.0 安裝具體步驟的內(nèi)容,感興趣的話就一起來看看這篇文章吧,相信看完通過源碼包方式實(shí)現(xiàn)MySQL-8.0 安裝具體步驟對(duì)大家多少有點(diǎn)參考價(jià)值吧。

創(chuàng)新互聯(lián)服務(wù)項(xiàng)目包括新市網(wǎng)站建設(shè)、新市網(wǎng)站制作、新市網(wǎng)頁制作以及新市網(wǎng)絡(luò)營銷策劃等。多年來,我們專注于互聯(lián)網(wǎng)行業(yè),利用自身積累的技術(shù)優(yōu)勢(shì)、行業(yè)經(jīng)驗(yàn)、深度合作伙伴關(guān)系等,向廣大中小型企業(yè)、政府機(jī)構(gòu)等提供互聯(lián)網(wǎng)行業(yè)的解決方案,新市網(wǎng)站推廣取得了明顯的社會(huì)效益與經(jīng)濟(jì)效益。目前,我們服務(wù)的客戶以成都為中心已經(jīng)輻射到新市省份的部分城市,未來相信會(huì)繼續(xù)擴(kuò)大服務(wù)區(qū)域并繼續(xù)獲得客戶的支持與信任!

1)安裝Mysql數(shù)據(jù)庫

[root@localhost ~]# rpm -q mysql mysql-server
未安裝軟件包 mysql 
未安裝軟件包 mysql-server 
[root@localhost ~]# yum -y install ncurses-devel
[root@localhost ~]# rpm -q ncurses-devel
ncurses-devel-5.9-14.20130511.el7_4.x86_64

安裝配置工具cmake

[root@localhost ~]# tar xf cmake-3.13.1.tar.gz -C /usr/src/
[root@localhost ~]# cd /usr/src/cmake-3.13.1/
[root@localhost cmake-3.13.1]# ./configure && gmake && gmake install

創(chuàng)建運(yùn)行用戶

[root@localhost ~]# useradd -M -s /sbin/nologin mysql

解包,配置,編譯,安裝

[root@localhost ~]# tar xf mysql-8.0.11.tar.gz -C /usr/src/
[root@localhost ~]# cd /usr/src/mysql-8.0.11/
[root@localhost mysql-5.7.24]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS=all -DSYSCONFDIR=/etc && make && make install

-DCMAKE_INSTALL_PREFIX=/usr/local/mysql     //數(shù)據(jù)庫程序安裝目錄
-DDEFAULT_CHARSET=utf8                  //指定字符集編碼
-DDEFAULT_COLLATION=utf8_general_ci         //默認(rèn)的字符集校對(duì)規(guī)則,utf8_general_ci適用于utf-8字符集的通用規(guī)則
-DWITH_EXTRA_CHARSETS=all               //指定額外支持的字符集編碼 
-DSYSCONFDIR=/etc                       //指定配置文件存放目錄

報(bào)錯(cuò)處理:

----------------------------------------------------------------------------------------------------------------------------
CMake Error at cmake/boost.cmake:81 (MESSAGE):
  You can download it with -DDOWNLOAD_BOOST=1 -DWITH_BOOST=<directory>

  This CMake script will look for boost in <directory>.  If it is not there,
  it will download and unpack it (in that directory) for you.

  If you are inside a firewall, you may need to use an http proxy:

  export http_proxy=http://example.com:80

Call Stack (most recent call first):
  cmake/boost.cmake:238 (COULD_NOT_FIND_BOOST)
  CMakeLists.txt:507 (INCLUDE)

-- Configuring incomplete, errors occurred!
See also "/usr/src/mysql-5.7.24/CMakeFiles/CMakeOutput.log".
See also "/usr/src/mysql-5.7.24/CMakeFiles/CMakeError.log".
----------------------------------------------------------------------------------------------------------------------------

解決辦法是:
1.在/usr/local下創(chuàng)建一個(gè)名為boost的文件夾

[root@localhost ~]# mkdir /usr/local/boost

2.進(jìn)入目錄并下載boost

[root@localhost ~]# cd /usr/local/boost
[root@localhost boost]# wget https://sourceforge.net/projects/boost/files/boost/1.66.0/boost_1_66_0.tar.gz

3.解壓boost

[root@localhost boost]# tar xf boost_1_66_0.tar.gz

4.繼續(xù)cmake,添加上紅色部分

[root@localhost mysql-5.7.24]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS=all -DSYSCONFDIR=/etc -DWITH_BOOST=/usr/local/boost && make && make install

2)安裝后的調(diào)整
對(duì)數(shù)據(jù)庫目錄進(jìn)行權(quán)限設(shè)置

[root@localhost ~]# cd /usr/local/mysql/
[root@localhost mysql]# chown -R mysql:mysql ./

建立配置文件(CentOS7系統(tǒng)默認(rèn)支持MariaDB數(shù)據(jù)庫,系統(tǒng)默認(rèn)的/etc/my.cnf配置文件是MariaDB的配置文件 )

[root@localhost mysql]# vim /etc/my.cnf
[mysqld]
datadir=/usr/local/mysql/data
socket=/tmp/mysql.sock

[mysqld_safe]
log-error=/usr/local/mysql/data/mysql.log
pid-file=/usr/local/mysql/data/mysql.pid

3)初始化數(shù)據(jù)庫

[root@localhost mysql]# ./bin/mysqld --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --initialize
2018-12-08T01:51:39.798903Z 1 [Note] A temporary password is generated for root@localhost: dskL0)8S3FGe

--basedir=/usr/local/mysql/         //指定安裝目錄(產(chǎn)品目錄)
--datadir=/usr/local/mysql/data     //指定數(shù)據(jù)目錄
--user=mysql                    //指定用戶身份

4)設(shè)置環(huán)境變量

[root@localhost mysql-5.7.24]# echo "PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile
[root@localhost mysql-5.7.24]# . /etc/profile  =  source /etc/profile

5)添加系統(tǒng)服務(wù)
添加MySQL為系統(tǒng)服務(wù),以便通過systemctl命令進(jìn)行管理

[root@localhost mysql-5.7.24]# cp support-files/mysql.server /usr/local/mysql/bin/mysqld.sh
[root@localhost mysql-5.7.24]# chmod +x /usr/local/mysql/bin/mysqld.sh
[root@localhost ~]# vim /usr/lib/systemd/system/mysqld.service
[Unit]
Description=MySQL Server
After=network.target

[Service]
User=mysql  #指定程序運(yùn)行的用戶賬戶
Group=mysql #指定程序運(yùn)行的組賬戶

Type=forking
PIDFile=/usr/local/mysql/data/localhost.pid #指定PID文件的位置,默認(rèn)為“主機(jī)名.pid”
ExecStart=/usr/local/mysql/bin/mysqld.sh start
ExecStop=/usr/local/mysql/bin/mysqld.sh stop

[Install]
WantedBy=mutil-user.target

[root@localhost ~]# systemctl start mysqld
[root@localhost ~]# systemctl enable mysqld
Created symlink from /etc/systemd/system/mutil-user.target.wants/mysqld.service to /usr/lib/systemd/system/mysqld.service.

[root@localhost ~]# systemctl status mysqld
● mysqld.service - MySQL Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: active (running) since 六 2018-12-08 09:54:04 CST; 42s ago
 Main PID: 2520 (mysqld)
   CGroup: /system.slice/mysqld.service
           ├─2364 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/usr/local/mysql/data --pid...
           └─2520 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/my...

12月 08 09:53:57 localhost systemd[1]: Starting MySQL Server...
12月 08 09:54:04 localhost systemd[1]: mysqld.service: Supervising process 2520 which is not...ts.
12月 08 09:54:04 localhost systemd[1]: Started MySQL Server.
12月 08 09:54:16 localhost systemd[1]: mysqld.service: Supervising process 2520 which is not...ts.
Hint: Some lines were ellipsized, use -l to show in full.

[root@localhost ~]# netstat -lnpt | grep mysqld
tcp6       0      0 :::3306                 :::*                    LISTEN      2520/mysqld

MySQL默認(rèn)通過TCP3306端口提供服務(wù),可通過編輯/etc/my.cnf文件中"port=3306"行進(jìn)行修改。

[root@localhost mysql]# mysqladmin -u root -p'dskL0)8S3FGe' password 123456
[root@localhost mysql]# mysql -uroot -p123456
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.11 Source distribution

Copyright (c) 2000, 2018, 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> exit
Bye

[root@localhost mysql]#

以上關(guān)于通過源碼包方式實(shí)現(xiàn)MySQL-8.0 安裝具體步驟詳細(xì)內(nèi)容,對(duì)大家有幫助嗎?如果想要了解更多相關(guān),可以繼續(xù)關(guān)注我們的行業(yè)資訊板塊。

網(wǎng)站標(biāo)題:通過源碼包方式實(shí)現(xiàn)MySQL-8.0安裝具體步驟
地址分享:http://muchs.cn/article22/phojcc.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站建設(shè)、關(guān)鍵詞優(yōu)化、做網(wǎng)站響應(yīng)式網(wǎng)站、外貿(mào)建站、商城網(wǎng)站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

小程序開發(fā)