MySQL5.7部署分類

本文主要給大家介紹MySQL 5.7部署分類,其所涉及的東西,從理論知識(shí)來獲悉,有很多書籍、文獻(xiàn)可供大家參考,從現(xiàn)實(shí)意義來講,創(chuàng)新互聯(lián)累計(jì)多年的實(shí)踐經(jīng)驗(yàn)可分享給大家。                                                    

讓客戶滿意是我們工作的目標(biāo),不斷超越客戶的期望值來自于我們對(duì)這個(gè)行業(yè)的熱愛。我們立志把好的技術(shù)通過有效、簡(jiǎn)單的方式提供給客戶,將通過不懈努力成為客戶在信息化領(lǐng)域值得信任、有價(jià)值的長(zhǎng)期合作伙伴,公司提供的服務(wù)項(xiàng)目有:主機(jī)域名、虛擬空間、營(yíng)銷軟件、網(wǎng)站建設(shè)、太子河網(wǎng)站維護(hù)、網(wǎng)站推廣。

MySQL5.7部署可以分為rpm包部署、源碼包部署、二進(jìn)制包部署。

源碼包部署:優(yōu)點(diǎn)是靈活性較高,可以自定義編譯參數(shù),效率高,缺點(diǎn)是部署時(shí)間較長(zhǎng)
二進(jìn)制包部署:優(yōu)點(diǎn)是事先已經(jīng)編譯好,部署較快,可以自定義一部分參數(shù),缺點(diǎn)是時(shí)間相比使用yum安裝,還是較長(zhǎng)
rpm包部署:優(yōu)點(diǎn)是部署速度快,缺點(diǎn)是定制性差
一般沒有特殊要求時(shí),可以使用yum包部署
下面開始使用二進(jìn)制包部署MySQL5.7.26二進(jìn)制包
下載地址:https://dev.mysql.com/downloads/mysql/5.7.html#downloads
在Select Operating System選項(xiàng)中選中”Linux Generic",在最下方的Linux - Generic (glibc 2.12) (x86, 64-bit), TAR項(xiàng)后方的download即可下載
1.添加MySQL數(shù)據(jù)庫運(yùn)行的用戶和用戶組

MySQL 5.7部署分類

groupadd -r mysql
useradd -r -g mysql mysql

2.此次MySQL部署的目錄為/application,將MySQL安裝包解壓到/application/mysql-5.7.26-linux-glibc2.12-x86_64目錄,并為此目錄創(chuàng)建軟鏈接

 ln -s /application/mysql-5.7.26-linux-glibc2.12-x86_64 /application/mysql

更改目錄權(quán)限
chown -R mysql:mysql /application/mysql-5.7.26-linux-glibc2.12-x86_64
3.初始化數(shù)據(jù)庫

/application/mysql-5.7.26-linux-glibc2.12-x86_64/bin/mysqld --initialize --user=mysql --basedir=/application/mysql --datadir=/application/mysql/data

[root@chanye application]# /application/mysql-5.7.26-linux-glibc2.12-x86_64/bin/mysqld --initialize --user=mysql --basedir=/application/mysql --datadir=/application/mysql/data
2019-06-18T08:35:49.103727Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2019-06-18T08:35:49.885283Z 0 [Warning] InnoDB: New log files created, LSN=45790
2019-06-18T08:35:49.944856Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2019-06-18T08:35:50.002905Z 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: 138aa81a-91a4-11e9-8f49-005056813525.
2019-06-18T08:35:50.004044Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2019-06-18T08:35:50.004493Z 1 [Note] A temporary password is generated for root@localhost: O;iSA6z>SieK

記住最后一行的臨時(shí)密碼
4.創(chuàng)建RSA  private key

/application/mysql/bin/mysql_ssl_rsa_setup --datadir=/application/mysql/data
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'

5.添加mysql到開機(jī)自啟動(dòng)

cp /application/mysql-5.7.26-linux-glibc2.12-x86_64/support-files/mysql.server /etc/init.d/mysqld

修改/etc/init.d/mysqld中的basedir和datadir

46 basedir=/application/mysql
 47 datadir=/application/mysql/data

加入開機(jī)自啟動(dòng)

chkconfig mysqld on
chkconfig --list mysqld
Note: This output shows SysV services only and does not include native
      systemd services. SysV configuration data might be overridden by native
      systemd configuration.

      If you want to list systemd services use 'systemctl list-unit-files'.
      To see services enabled on particular target use
      'systemctl list-dependencies [target]'.

mysqld          0:off   1:off   2:on    3:on    4:on    5:on    6:off

修改全局配置文件將mysql可執(zhí)行路徑加入到PATH,在/etc/profile最后一行添加:

export PATH=/application/mysql/bin:$PATH

使用source /etc/profile使配置生效
刪掉系統(tǒng)自帶的/etc/my.cnf或者改名,在/application/mysql/目錄新建my.cnf,并且將文件屬性調(diào)整為mysql:mysql

[mysqld]
character-set-server=utf8
datadir=/application/mysql/data
socket=/application/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd

#
# include all files from the config directory
#
!includedir /etc/my.cnf.d

[client]
character-set-server=utf8
socket=/application/mysql/mysql.sock

[mysql]
character-set-server=utf8
socket=/application/mysql/mysql.sock

6.啟動(dòng)mysql
啟動(dòng)mysql

/etc/init.d/mysqld start

此時(shí)使用初始化提供的密碼進(jìn)行登陸

# mysql -uroot -p
Enter password: 
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

系統(tǒng)默認(rèn)的客戶端使用的mysql.sock文件是基于unix sock的,此時(shí)最簡(jiǎn)便的辦法是創(chuàng)建一個(gè)軟鏈接

ln -s /application/mysql/mysql.sock /tmp/mysql.sock

如果不創(chuàng)建軟鏈接,使用mysql命令登陸的時(shí)候使用-S選項(xiàng),手工指定mysql.sock的位置也是可以登陸的
登陸成功后需要更改管理員密碼

alter user 'root'@'localhost' identified by '598545$kdOctamvsU';
flush privileges;

查看mysql狀態(tài)

mysql> status;
--------------
mysql  Ver 14.14 Distrib 5.7.26, for linux-glibc2.12 (x86_64) using  EditLine wrapper

Connection id:      4
Current database:   
Current user:       root@localhost
SSL:            Not in use
Current pager:      stdout
Using outfile:      ''
Using delimiter:    ;
Server version:     5.7.26 MySQL Community Server (GPL)
Protocol version:   10
Connection:     Localhost via UNIX socket
Server characterset:    utf8
Db     characterset:    utf8
Client characterset:    utf8
Conn.  characterset:    utf8
UNIX socket:        /application/mysql/mysql.sock
Uptime:         7 min 56 sec

Threads: 2  Questions: 14  Slow queries: 0  Opens: 116  Flush tables: 1  Open tables: 109  Queries per second avg: 0.029

--------------

看了以上介紹MySQL 5.7部署分類,希望能給大家在實(shí)際運(yùn)用中帶來一定的幫助。本文由于篇幅有限,難免會(huì)有不足和需要補(bǔ)充的地方,大家可以繼續(xù)關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊板塊,會(huì)定期給大家更新行業(yè)新聞和知識(shí),如有需要更加專業(yè)的解答,可在官網(wǎng)聯(lián)系我們的24小時(shí)售前售后,隨時(shí)幫您解答問題的。

本文名稱:MySQL5.7部署分類
文章轉(zhuǎn)載:http://muchs.cn/article40/iheseo.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站設(shè)計(jì)公司、標(biāo)簽優(yōu)化建站公司、、全網(wǎng)營(yíng)銷推廣、面包屑導(dǎo)航

廣告

聲明:本網(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)

手機(jī)網(wǎng)站建設(shè)