共计 5406 个字符,预计需要花费 14 分钟才能阅读完成。
本篇内容主要讲解“MySQL 的 rpm 安装方式”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让丸趣 TV 小编来带大家学习“MySQL 的 rpm 安装方式”吧!
用于安装 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-server, mysql-community-client, mysql-community-libs, mysql-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
mysqld server
/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 可用的文件描述符的限制。
到此,相信大家对“MySQL 的 rpm 安装方式”有了更深的了解,不妨来实际操作一番吧!这里是丸趣 TV 网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!