CentOS 6.9 自訂單一實例 二進位方式 安裝mysql5.7.21

來源:互聯網
上載者:User

標籤:二進位方式 安裝mysql5.7.21   Centos 5.7   

前言
比 MySQL 5.6 快 3 倍,同時還提高了可用性,可管理性和安全性。一些重要的增強功能如下:1.效能和可擴充性:    改進 InnoDB 的可擴充性和暫存資料表的效能,從而實現更快的網路和大資料載入等操作。2.JSON支援:    使用 MySQL 的 JSON 功能,你可以結合 NoSQL 的靈活和關聯式資料庫的強大。3.改進複製    以提高可用性的效能。包括多源複製,多從線程增強,線上 GTIDs,和增強半同步複製。4.效能模式    提供更好的視角。我們增加了許多新的監控功能,以減少空間和過載,使用新的 SYS 模式顯著提高易用性。5.安全:    我們貫徹“安全第一”的要求,許多 MySQL 5.7 新功能協助使用者保證他們資料庫的安全。6.最佳化:    我們重寫了大部分解析器,最佳化器和成本模型。這提高了可維護性,可擴充性和效能。7.GIS:     MySQL 5.7 全新的功能,包括 InnoDB 空間索引,使用 Boost.Geometry,同時提高完整性和標準符合性。
實驗環境:VMware Workstation Pro 14(試用版)系統平台:CentOS release 6.9 (Final)             核心  2.6.32-696.el6.x86_64
1.去官網下載適合的二進位包

https://dev.mysql.com/downloads/mysql/

mysql-5.7.21-linux-glibc2.12-x86_64.tar.gz

檢查系統內是否安裝了資料庫。

#rpm -qa|grep MariaDB#rpm -qa|grep mysql
2.建立用於啟動mysql的帳號和組
#getent group mysql > /dev/null || groupadd mysql#getent passwd mysql > /dev/null || useradd -g mysql -r -s /sbin/nologin mysql
3.解壓包至/usr/local
#tar xvf mysql-5.7.21-linux-glibc2.12-x86_64.tar.gz -C /usr/local/
4.建立軟連結mysql指向解壓後的目錄
#cd /usr/local/#ln -s mysql-5.7.21-linux-glibc2.12-x86_64/ mysql
5.修改mysql檔案夾所屬者和所屬組
#chown -R mysql.mysql mysql/
6.添加PATH至環境變數中
#echo ‘PATH=/usr/local/mysql/bin:$PATH‘ >> /etc/profile.d/mysql.sh檢查檔案#cat /etc/profile.d/mysql.sh載入環境變數檔案 並檢查#source /etc/profile.d/mysql.sh#echo $PATH
7.建立資料庫存放檔案夾和相關檔案並修改許可權
#mkdir -pv /data/mysqldb/3306/{logs,run,data}#touch /data/mysqldb/3306/run/mysqld.pid#touch /data/mysqldb/3306/logs/mysql-error.log#chown -R mysql.mysql /data/mysqldb/#chmod -R 770 /data/mysqldb檔案沒有建立的話,啟動Mysql時將會報錯
8.修改設定檔
#vim /etc/my.cnf[client]  port = 3306  socket = /var/lib/mysql/mysql.sock    > 預設就是在這裡[mysqld]  user=mysql  port = 3306  socket=/var/lib/mysql/mysql.sock  basedir =/usr/local/mysqldatadir =/data/mysqldb/3306/data pid-file=/data/mysqldb/3306/run/mysqld.pid log-error=/data/mysqldb/3306/logs/mysql-error.log 
9.初始化資料庫
# cd /usr/local/mysql# bin/mysqld --defaults-file=/etc/my.cnf --initialize-insecure --user=mysql --datadir=/data/mysqldb/3306/dataMysql 5.7以後對密碼安全有更友好的提示了,2018-03-03T15:16:23.708677Z 1 [Warning] [email protected] is created with an empty password ! Please consider switching off the --initialize-insecure option.--initialize-insecure 以空密碼初始化資料庫--initialize          隨機產生一個密碼並顯示在螢幕中,第一次登入的時候必須提供此密碼。
10.複製啟動服務指令碼至/etc/init.d目錄
#cp mysql/support-files/mysql.server /etc/rc.d/init.d/mysqld
11.添加開機啟動
# chkconfig --add mysqld# chkconfig mysqld on#chkconfig --list mysqldmysqld          0:off   1:off   2:on    3:on    4:on    5:on    6:off
12.啟動mysql服務
#service mysqld startStarting MySQL........                                     [  OK  ]
13.檢查確認

檢查3306連接埠是否開啟

#ss -ntl | grep 3306LISTEN     0      50                        *:3306                     *:*

確認版本

#mysql -Vmysql  Ver 14.14 Distrib 5.7.21, for linux-glibc2.12 (x86_64) using  EditLine wrapper
14.進行安全配置
#/usr/local/mysql/bin/mysql_secure_installation按提示操作即可Press y|Y for Yes, any other key for No: y       > 沒有y就沒有下一步There are three levels of password validation policy:                       > 列出密碼要求LOW    Length >= 8MEDIUM Length >= 8, numeric, mixed case, and special charactersSTRONG Length >= 8, numeric, mixed case, special characters and dictionary Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 0                          > 選擇的數字,請參考上面的密碼要求Please set the password for root here.New password:                                                               > 設定密碼Re-enter new password: Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y  > 更新密碼Remove anonymous users? (Press y|Y for Yes, any other key for No) : y    > 是否移除匿名登入Disallow root login remotely? (Press y|Y for Yes, any other key for No) : n   > 是否移除遠程root登入,生產環境請yRemove test database and access to it? (Press y|Y for Yes, any other key for No) : y  > 是否移除test資料庫,貌似二進位安裝時並不包含test資料庫Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y   > 重新載入許可權表,也就是立即生效。Success. All done! 
15.用戶端串連
#mysql -uroot -pEnter password: Welcome to the MySQL monitor.  Commands end with ; or \g.Your MySQL connection id is 6Server version: 5.7.21 MySQL Community Server (GPL)Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.mysql> 

至此,Mysql 5.7.21 二進位方式安裝完畢,適合快速部署。

CentOS 6.9 自訂單一實例 二進位方式 安裝mysql5.7.21

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.