R1-002 MySQL的rpm安裝方式

路途中的人2012發表於2017-02-22
Installing MySQL on Linux Using RPM Packages from Oracle
基於rpm的Linux MySQL安裝包的推薦安裝方式是使用Oracle提供的rpm包來安裝。對於社群版的MySQL,有兩種方式來獲取安裝包:MySQL的軟體庫(包括MySQL yum源和MySQL sles庫)、MySQL開發者空間的下載MySQL社群版伺服器介面。

用於安裝MySQL的rpm包如下:
Table 2.6 RPM Packages for MySQL Community Edition
Package Name Summary
mysql-community-server Database server and related tools 資料庫伺服器和相關工具
mysql-community-client MySQL client applications and tools MySQL客戶端應用程式和工具
mysql-community-common Common files for server and client libraries 伺服器和客戶端庫庫的通用檔案
mysql-community-devel Development header files and libraries for MySQL database client applications
mysql-community-libs Shared libraries for MySQL database client applications
mysql-community-libs-compat Shared compatibility libraries for previous MySQL installations
mysql-community-embedded MySQL embedded library
mysql-community-embedded-devel Development header files and libraries for MySQL as an embeddable library
mysql-community-test Test suite for the MySQL server

Table 2.7 RPM Packages for the MySQL Enterprise Edition
Package Name Summary
mysql-commercial-server Database server and related tools
mysql-commercial-client MySQL client applications and tools
mysql-commercial-common Common files for server and client libraries
mysql-commercial-devel Development header files and libraries for MySQL database client applications
mysql-commercial-libs Shared libraries for MySQL database client applications
mysql-commercial-libs-compat Shared compatibility libraries for previous MySQL installations
mysql-commercial-embedded MySQL embedded library
mysql-commercial-embedded-devel Development header files and libraries for MySQL as an embeddable library
mysql-commercial-test Test suite for the MySQL server

rpm包的語法格式:
packagename-version-distribution-arch.rpm
The distribution and arch values indicate the Linux distribution and the processor type for which the package was built. See the table below for lists of the distribution identifiers:
Table 2.8 MySQL Linux RPM Package Distribution Identifiers
distribution Value Intended Use
el5, el6, el7 Red Hat Enterprise Linux/Oracle Linux/CentOS 5, 6, or 7
fc22, fc23 Fedora 22 or 23
sles12 SUSE Linux Enterprise Server 12

檢視rpm包中所有檔案(for example, mysql-community-server):
shell> rpm -qpl mysql-community-server-version-distribution-arch.rpm
本章剩餘章節只適合從Oracle下載的包的安裝過程,不適用於MySQL庫的安裝。
包中存在一些依賴關係。如果你打算安裝好幾個包,你應該選擇下載tar格式的rpm包群,包群裡包含了上述所有包,如此一來你便不用分別下載它們。

大多數情況下,你需要安裝mysql-community-servermysql-community-clientmysql-community-libsmysql-community-common, and mysql-community-libs-compat這五個包來得到一個可用的、標準的MySQL系統。要執行這樣一個標準的、最小化的安裝,切換到這些包所在的資料夾的路徑,在除了Red Hat Enterprise Linux/Oracle Linux/CentOS 5平臺下執行如下命令:
shell> sudo yum install mysql-community-{server,client,common,libs}-*
Replace yum with zypper for SLES systems, and with dnf for dnf-enabled systems (like Fedora 22).

對於Red Hat Enterprise Linux/Oracle Linux/CentOS 5平臺,有一個額外的包需要安裝:mysql-version-el5-arch.rpm,使用如下命令:
shell> sudo yum install mysql-community-{server,client,common,libs}-* mysql-5.*

儘管使用一個高階的包管理工具例如yum來安裝包會是極佳的選擇,但是仍有使用者喜歡直接使用rpm的命令rpm -Uvh來安裝,這種方式會增加失敗的風險,因為可能會遇到潛在的依賴包的問題。
To install only the client programs, you can skip mysql-community-server in your list of packages to install; issue the following command for platforms other than Red Hat Enterprise Linux/Oracle Linux/CentOS 5:
shell> sudo yum install mysql-community-{client,common,libs}-*
Replace yum with zypper for SLES systems, and with dnf for dnf-enabled systems (like Fedora 22).
For Red Hat Enterprise Linux/Oracle Linux/CentOS 5 systems:
shell> sudo yum install mysql-community-{client,common,libs}-* mysql-5.*
A standard installation of MySQL using the RPM packages result in files and resources created under the system directories, shown in the following table.

MySQL安裝的預設佈局如下:
Table 2.9 MySQL Installation Layout for Linux RPM Packages from the MySQL Developer Zone
Files or Resources Location
Client programs and scripts /usr/bin
/usr/sbin
Configuration file /etc/my.cnf
Data directory /var/lib/mysql
Error log file For RHEL, Oracle Linux, CentOS or Fedora platforms: /var/log/mysqld.log
For SLES: /var/log/mysql/mysqld.log
Value of secure_file_priv /var/lib/mysql-files
System V init script For RHEL, Oracle Linux, CentOS or Fedora platforms: /etc/init.d/mysqld
For SLES: /etc/init.d/mysql
Systemd service For RHEL, Oracle Linux, CentOS or Fedora platforms: mysqld
For 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

安裝同時會在作業系統上建立一個名為mysql的使用者和一個名為mysql的組。

Note
使用舊的安裝包來安裝原來的版本的MySQL可能會建立一個叫做/usr/my.cnf的配置檔案。強烈建議您檢查該檔案的內容並將有用的設定遷移到檔案/etc/my.cnf中,然後移除/usr/my.cnf。

在安裝過程的最後,MySQL並不會自動啟動。對於Red Hat Enterprise Linux, Oracle Linux, CentOS, and Fedora systems,使用如下命令啟動MySQL:
shell> sudo service mysqld start
對於For SLES systems, 命令一樣,但是服務名不同:
shell> sudo service mysql start
如果作業系統啟用了systemd,那麼標準的service命令例如stop,start,status以及restart都應該可以用來管理MySQL伺服器的服務。mysqld服務預設開啟,並跟隨系統啟動。注意,有些事情在systemd平臺上會表現的不一致:例如,改變資料目錄的位置可能會產生問題。
At the initial start up of the server, the following happens, given that the data directory of the server is empty:
在伺服器初始化啟動階段,會發生下列事情,前提是該伺服器的資料目錄沒資料:
  • 伺服器初始化。
  • 一個SSL證照和金鑰檔案在資料目錄中產生。
  • validate_password plugin外掛安裝並生效。
  • 一個超級使用者帳號'root'@'localhost'建立。該超級使用者的密碼已設定並儲存在錯誤日誌檔案中。要找到它,RHEL, Oracle Linux, CentOS, and Fedora systems使用如下命令:
shell> sudo grep 'temporary password' /var/log/mysqld.log
Use the following command for SLES systems:
shell> sudo grep 'temporary password' /var/log/mysql/mysqld.log
接下來是利用剛生成的臨時密碼登入資料庫併為該超級使用者帳號設定一個典型的密碼:
shell> mysql -uroot -p
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';
Note
MySQL預設安裝 validate_password外掛。該外掛要求密碼包含至少一個大寫字母,一個小寫字母,一個數字以及一個特殊字元,同時密碼長度至少8位。
如果安裝過程中出現錯誤,你可以去錯誤日誌檔案/var/log/mysqld.log查詢相關資訊。對於某些Linux平臺,有必要提高對mysqld可用的檔案描述符的限制。


root passwords for pre-GA releases.  For MySQL 5.7.4 and 5.7.5, the initial random root password is written to the .mysql_secret file in the directory named by the HOME environment variable. When trying to access the file, bear in mind that depending on operating system, using a command such as sudo may cause the value of HOME to refer to the home directory of the root system user . .mysql_secret is created with mode 600 to be accessible only to the system user for whom it is created. Before MySQL 5.7.4, the accounts (including root) created in the MySQL grant tables for an RPM installation initially have no passwords; after starting the server, you should assign passwords to them using the instructions in ."

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29067253/viewspace-2134136/,如需轉載,請註明出處,否則將追究法律責任。

相關文章