KVMMYSQL5.7單機FOROEL7.5安裝文檔的方法是什么

這篇文章主要介紹“KVM MySQL 5.7單機FOR  OEL7.5安裝文檔的方法是什么”,在日常操作中,相信很多人在KVM MYSQL 5.7單機FOR  OEL7.5安裝文檔的方法是什么問題上存在疑惑,小編查閱了各式資料,整理出簡單好用的操作方法,希望對大家解答”KVM MYSQL 5.7單機FOR  OEL7.5安裝文檔的方法是什么”的疑惑有所幫助!接下來,請跟著小編一起來學習吧!

創(chuàng)新互聯(lián)-專業(yè)網(wǎng)站定制、快速模板網(wǎng)站建設、高性價比昔陽網(wǎng)站開發(fā)、企業(yè)建站全套包干低至880元,成熟完善的模板庫,直接使用。一站式昔陽網(wǎng)站制作公司更省心,省錢,快速模板網(wǎng)站建設找我們,業(yè)務覆蓋昔陽地區(qū)。費用合理售后完善,十多年實體公司更值得信賴。

1. KVM MYSQL 5.7 單機 FOR  OEL7.5 通常安裝文檔

2. 安裝流程

2.1. 確定平臺版本和機器位數(shù)。

確定當前MYSQL版本對應各種操作系統(tǒng) 平臺是否支持。

2.2. 下載對應版本

2.2.1. 下載二進制安裝包

?    官方網(wǎng)站
?     http://dev.mysql.com/downloads/mirrors.html .
?    進入后可以選擇對應的版本

NOTE:
tar.gz tar.xz 為二進制安裝。
RPM 為rpm 安裝包。
deb 為 deband linux 安裝包.
PKG 為mac 文件安裝包。

2.2.2. 下載yum 源配置包(社區(qū)版)

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

2.2.3. 下載源碼編譯

?    源碼現(xiàn)目前在GIT 上托管。

2.3. 驗證下載后文件是否正確

  • LINUX  AND WINDOWS MD5 驗證

    shell> md5sum mysql-standard-8.0.13-linux-i686.tar.gz
    aaab65abbec64d5e907dcd41b8699945  mysql-standard-8.0.13-linux-i686.tar.gz
shell> md5.exe mysql-installer-community-8.0.13.msi
aaab65abbec64d5e907dcd41b8699945  mysql-installer-community-8.0.13.msi
  • RPM 包驗證

    shell> rpm --checksig MySQL-server-8.0.13-0.linux_glibc2.5.i386.rpm
    MySQL-server-8.0.13-0.linux_glibc2.5.i386.rpm: md5 gpg OK

    3. 二進制部署

    NOTE:
    使用二進制安裝這種模式不同于yum 安裝自動分析相關依賴包。必須首先移除mariadb或者以前的安裝過mysql 的配置文件。例如/etc/my.conf.

  • 卸載mariadb

    shell> yum remove mariadb*
  • 安裝依賴包

    shell> yum search libaio  # search for info
    shell> yum install libaio # install library

    3.1. 安裝目錄說明

    3.2. 安裝MySQL

    3.2.1. 創(chuàng)建MySQL用戶和組

    shell> groupadd mysql
    shell> useradd -r -g mysql -s /bin/false mysql

    3.2.2. 解壓軟件

shell> cd /usr/local
shell> tar zxvf /path/to/mysql-VERSION-OS.tar.gz
shell> gunzip < /path/to/mysql-VERSION-OS.tar.gz | tar xvf -

3.2.3. 創(chuàng)建新的鏈接文件到真實目錄

shell> ln -s full-path-to-mysql-VERSION-OS mysql

3.2.4. 設置環(huán)境變量

shell> export PATH=$PATH:/usr/local/mysql/bin

3.2.5. 配置啟動目錄

shell> cd mysql
shell> mkdir mysql-files
shell> chown mysql:mysql mysql-files
shell> chmod 750 mysql-files

3.2.6. 初始化數(shù)據(jù)庫

shell> bin/mysqld --initialize --user=mysql
3.2.6.1. 初始化數(shù)據(jù)庫兩種方式
shell> bin/mysqld --initialize --user=mysql
shell> bin/mysqld --initialize-insecure --user=mysql

NOTE:

兩種初始化方式第一種必須強制使用密碼登錄
第二種方式可以使用跳過密碼
shell> mysql -u root --skip-password
然后更改對應密碼
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';
在mysql 8.0 默認加密的密碼已經(jīng)改了?,F(xiàn)在默認使用caching_sha2_password 加密方式。
如果還需使用默認的mysql_native_password 加密方式的話使用默認 模式。
初始化的時候,默認路徑為/usr/local/mysql

3.2.6.2. 更改默認路徑
  • 如果要改變安裝目錄使用以下目錄:

    shell> bin/mysqld --initialize --user=mysql
           --basedir=/opt/mysql/mysql
           --datadir=/opt/mysql/mysql/data
  • 配置文件

    [mysqld]
    basedir=/opt/mysql/mysql
    datadir=/opt/mysql/mysql/data
  • 使用配置文件指定位置:

  • 范例

    shell> bin/mysqld --initialize-insecure --user=mysql \
    --basedir=/app/mysql \
           --datadir=/app/mysql/mysql-files
  • 輸出日志:

    [root
    
    @mysql1
    
     mysql]# bin/mysqld --initialize-insecure --user=mysql \
    > --basedir=/app/mysql \
    >          --datadir=/app/mysql/mysql-files
    2018-09-28T16:18:32.178288Z 0 [System] [MY-013169] [Server] /app/mysql-commercial-8.0.12-el7-x86_64/bin/mysqld (mysqld 8.0.12-commercial) initializing of server in progress as process 5328
    2018-09-28T16:18:46.268910Z 5 [Warning] [MY-010453] [Server] root
    
    @localhost
    
     is created with an empty password ! Please consider switching off the --initialize-insecure option.
    2018-09-28T16:18:57.082553Z 0 [System] [MY-013170] [Server] /app/mysql-commercial-8.0.12-el7-x86_64/bin/mysqld (mysqld 8.0.12-commercial) initializing of server has completed

3.2.7. 創(chuàng)建安全連接

3.2.7.1. 說明
FormatDescription
—datadirPath to data directory
—helpDisplay help message and exit
—suffixSuffix for X509 certificate Common Name attribute
—uidName of effective user to use for file permissions
—verboseVerbose mode
—versionDisplay version information and exit
3.2.7.2. 默認目錄
shell> bin/mysql_ssl_rsa_setup
3.2.7.3. 指定目錄
bin/mysql_ssl_rsa_setup --datadir=/app/mysql/mysql-files/

———————————到此安裝完畢—————————————————-

4. YUM 源安裝

a.    去下載MySQL 的repo 文件: http://dev.mysql.com/downloads/repo/yum/

wget https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm

b.    選擇對應操作系統(tǒng)版本的
c.    本地安裝

shell> sudo yum localinstall platform-and-version-specific-package-name.rpm
  • EL6-based system

    shell> sudo yum localinstall mysql80013-community-release-el6-{version-number}.noarch.rpm
  • EL7-based system:

    shell> sudo yum localinstall mysql80013-community-release-el7-{version-number}.noarch.rpm
  • Fedora 28:

    shell> sudo dnf localinstall mysql80013-community-release-fc28-{version-number}.noarch.rpm
  • Fedora 27:

    shell> sudo dnf localinstall mysql80013-community-release-fc27-{version-number}.noarch.rpm
  • 范例:

    yum localinstall mysql80-community-release-el7-1.noarch.rpm
  • 查看已經(jīng)啟用MySQL 源

    yum repolist enabled | grep "mysql.*-community.*"
  • 啟用集群安裝

    mysql-cluster
  • 查看所有mysql 有關的安裝源

    shell> yum repolist all | grep mysql
  • 開啟對應安裝yum源

    shell> sudo yum-config-manager --disable mysql57-community
    shell> sudo yum-config-manager --enable mysql80-community
  • 例如:
    開啟集群

    shell> sudo yum-config-manager --enable mysql-cluster-7.6-community

  • 安裝MYSQL

    yum install mysql-community-server

5. 使用RPM 包安裝

說明:

由于企業(yè)版只提供二進制和RPM 包方式。。不提供YUM 安裝方式。
以下是各個RPM 包的含義:

Package NameSummary
mysql-commercial-backupMySQL Enterprise Backup (added in 8.0.11)
mysql-commercial-clientMySQL client applications and tools
mysql-commercial-commonCommon files for server and client libraries
mysql-commercial-develDevelopment header files and libraries for MySQL database client applications
mysql-commercial-embedded-compatMySQL server as an embedded library with compatibility for applications using version 18 of the library
mysql-commercial-libsShared libraries for MySQL database client applications
mysql-commercial-libs-compatShared compatibility libraries for previous MySQL installations; the version of the libraries matches the version of the libraries installed by default by the distribution you are using
mysql-commercial-minimal-debuginfoDebug information for package mysql-commercial-server-minimal; useful when developing applications that use this package or when debugging this package
mysql-commercial-serverDatabase server and related tools
mysql-commercial-server-minimalMinimal installation of the database server and related tools (added in 8.0.0)
mysql-commercial-testTest suite for the MySQL server
  1. 下載對應版本的RPM 包進行解壓

    [root
    
    @mysql3
    
     ~]# unzip V979091-01.zip 
    Archive:  V979091-01.zip
    extracting: mysql-commercial-libs-8.0.12-1.1.el7.x86_64.rpm  
    extracting: mysql-commercial-embedded-compat-8.0.12-1.1.el7.x86_64.rpm  
    extracting: mysql-commercial-test-8.0.12-1.1.el7.x86_64.rpm  
    extracting: mysql-commercial-server-8.0.12-1.1.el7.x86_64.rpm  
    extracting: mysql-commercial-server-minimal-8.0.12-1.1.el7.x86_64.rpm  
    extracting: mysql-commercial-minimal-debuginfo-8.0.12-1.1.el7.x86_64.rpm  
    extracting: mysql-commercial-devel-8.0.12-1.1.el7.x86_64.rpm  
    extracting: mysql-commercial-client-8.0.12-1.1.el7.x86_64.rpm  
    extracting: mysql-commercial-libs-compat-8.0.12-1.1.el7.x86_64.rpm  
    extracting: mysql-commercial-common-8.0.12-1.1.el7.x86_64.rpm  
    extracting: mysql-commercial-backup-8.0.12-1.1.el7.x86_64.rpm  
    extracting: README.txt
  2. 批量自動安裝:自動解決依賴包。使用此命令時注意不要和server_mini 混用。

    yum install mysql-commercial-*
  • 簡易服務端

    sudo yum install mysql-community-{server,client,common,libs}-*
  • 簡易客戶端

    yum install mysql-community-{client,common,libs}-*
  • 目錄分布

Files or ResourcesLocation
Client programs and scripts/usr/bin
mysqld server/usr/sbin
Configuration file/etc/my.cnf
Data directory/var/lib/mysql
Error log fileFor RHEL, Oracle Linux, CentOS or Fedora platforms: /var/log/mysqld.logFor SLES: /var/log/mysql/mysqld.log
Value of secure_file_priv/var/lib/mysql-files
System V init scriptFor RHEL, Oracle Linux, CentOS or Fedora platforms: /etc/init.d/mysqldFor SLES: /etc/init.d/mysql
Systemd serviceFor RHEL, Oracle Linux, CentOS or Fedora platforms: mysqldFor SLES: mysql
Pid file/var/run/mysql/mysqld.pid
Socket/var/lib/mysql/mysql.sock
Keyring directory/var/lib/mysql-keyring
Unix manual pages/usr/share/man
Include (header) files/usr/include/mysql
Libraries/usr/lib/mysql
Miscellaneous support files (for example, error messages, and character set files)/usr/share/mysql

5.1. 安裝相關組件

列出開啟yum 中所有相關的安裝包。,包括未enable 中的源
例如主機上要連接低版本客戶端。則需要安裝低版本客戶端如下:

rpm --oldpackage -ivh mysql-community-libs-5.5.50-2.el6.x86_64.rpm

安裝其他軟件:到官網(wǎng)下載對應版本安裝。

6. 啟動和關閉

6.1. 使用二進制安裝

 shell> bin/mysqld_safe --user=mysql &
# 6. Next command is optional

6.1.1. 拷貝自啟動文件

shell> cp /app/mysql/support-files/mysql.server /etc/init.d/

6.1.2. 編輯my.cnf 文件

basedir=/app/mysql
datadir=/app/mysql/mysql-files

6.1.3. 重載啟動項目

systemctl  daemon-reload

6.1.4. 查看是否啟動MySQL

systemctl  status mysql

6.1.5. 開機自啟動

NOTE:
由于使用二進制安裝,則需要配置chkconfig 。RPM 包不需要

chkconfig --add mysql.server
chkconfig mysql.server on

6.2. 使用yum 源安裝

6.2.1. 啟動MySQL

service mysqld start
systemctl  start mysqld

6.2.2. 查看是否啟動MySQL

systemctl  status mysqld

6.2.3. 開機自啟動

systemctl  enable mysqld
systemctl disable mysqld

6.3. 使用RPM 包安裝

6.3.1. 啟動MySQL

service mysqld start
systemctl  start mysqld

6.3.2. 查看是否啟動MySQL

systemctl  status mysqld

6.3.3. 開機自啟動

systemctl  enable mysqld
systemctl disable mysqld

7. MySQL 啟動后診斷

7.1. 查看日志

tail host_name.err

7.2. 選擇驅動

默認為InnoDB

7.3. 確認數(shù)據(jù)文件位置是否合適

7.4. 查看所有配置參數(shù)和所有的環(huán)境變量

mysqld --basedir=/app/mysql --verbose –help | more

7.5. 配置文件環(huán)境變量

mysqladmin variables -u root -p 
mysqladmin -h host_name variables - u root -p

8. 測試MySQL

  • 檢查mysql 是否正常運行

    mysqladmin version
  • 檢查配置變量值

    mysqladmin variables
  • 檢查是否能登陸

    mysqladmin -u root -p version
  • 關閉mysql 服務

    mysqladmin -u root shutdown
  • 顯示mysql 數(shù)據(jù)庫

    mysqlshow
  • 顯示某個數(shù)據(jù)庫中的表

    mysqlshow mysql
  • shell 界面查詢表數(shù)據(jù)

    mysql -e "SELECT User, Host, plugin FROM mysql.user" mysql

NOTE:

以上命令成功執(zhí)行后則mysql 數(shù)據(jù)正常。

9. 賬戶安全

9.1. yum 源安裝

  • 臨時密碼:

    grep 'temporary password' /var/log/mysqld.log
  • 登錄:

    mysql -uroot -p
  • 更改密碼:

    ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';
  • 由于密碼復雜度有相關要求:但是測試不需要則

mysql> SHOW VARIABLES LIKE 'validate_password%';
+--------------------------------------+--------+
| Variable_name                        | Value  |
+--------------------------------------+--------+
| validate_password.check_user_name    | ON     |
| validate_password.dictionary_file    |        |
| validate_password.length             | 8      |
| validate_password.mixed_case_count   | 1      |
| validate_password.number_count       | 1      |
| validate_password.policy             | MEDIUM |
| validate_password.special_char_count | 1      |
+--------------------------------------+--------+
7 rows in set (0.01 sec)
set GLOBAL validate_password.policy=0;
設置密碼長度
set GLOBAL validate_password.length=3;
  • 設置密碼復雜度為低。更方便測試。

ALTER USER 'root'@'localhost' IDENTIFIED BY '1234';

9.2. 二進制安裝

  • 使用mysqld —insecure初始化后的密碼更改

mysql -u root -p
ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';
  • 如果使用mysqld —initialize-insecure 進行初始化
    則:

    mysql -u root --skip-password

  • 更改密碼:

    ALTER USER 'root'@'localhost' IDENTIFIED BY '123'

    9.3. RPM 包安裝

  • 臨時密碼:

    grep 'temporary password' /var/log/mysqld.log
  • 登錄:

    mysql -uroot -p
  • 更改密碼:

    ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';
  • 由于密碼復雜度有相關要求:但是測試不需要則

mysql> SHOW VARIABLES LIKE 'validate_password%';
+--------------------------------------+--------+
| Variable_name                        | Value  |
+--------------------------------------+--------+
| validate_password.check_user_name    | ON     |
| validate_password.dictionary_file    |        |
| validate_password.length             | 8      |
| validate_password.mixed_case_count   | 1      |
| validate_password.number_count       | 1      |
| validate_password.policy             | MEDIUM |
| validate_password.special_char_count | 1      |
+--------------------------------------+--------+
7 rows in set (0.01 sec)
mysql> set GLOBAL validate_password.policy=0;
mysql> set GLOBAL validate_password.length=3;
  • 設置密碼復雜度為低。更方便測試。

ALTER USER 'root'@'localhost' IDENTIFIED BY '1234';

10. 附錄

10.1. 忘記root 密碼

  • 方法1:

    kill `cat /mysql-data-directory/host_name.pid`
  • 把以下語句保存到文件中

    ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';

    例如:/root/mysql-init

  • 開始改變密碼

    mysqld --init-file=/home/me/mysql-init &

    mysql 服務會自動啟動。

  • 然后刪除保存密碼的文件。
    方法2:
    添加my.cnf 選項

    skip-grant-tables:

  • 重啟MySQL

  • 更改密碼

    mysql
    update user set password=password("new_pass") where user="root";
    FLUSH PRIVILEGES;
    ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';

到此,關于“KVM MYSQL 5.7單機FOR  OEL7.5安裝文檔的方法是什么”的學習就結束了,希望能夠解決大家的疑惑。理論與實踐的搭配能更好的幫助大家學習,快去試試吧!若想繼續(xù)學習更多相關知識,請繼續(xù)關注創(chuàng)新互聯(lián)網(wǎng)站,小編會繼續(xù)努力為大家?guī)砀鄬嵱玫奈恼拢?/p>

文章標題:KVMMYSQL5.7單機FOROEL7.5安裝文檔的方法是什么
標題來源:http://www.muchs.cn/article8/ijseop.html

成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供關鍵詞優(yōu)化、移動網(wǎng)站建設服務器托管、品牌網(wǎng)站建設、品牌網(wǎng)站設計Google

廣告

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

手機網(wǎng)站建設