MySQL学习笔记2-System administration(Installing MySQL on Linux Using RPM Packages)
2015-11-11 19:55
936 查看
2.5.5 Installing MySQL on Linux Using RPM Packages
NoteTo install or upgrade to MySQL 5.7.2 or later, be sure to read the special instructions at the end of this section.
The recommended way to install MySQL on RPM-based Linux distributions that use
glibcis
by using the RPM packages provided by Oracle. There are two sources for obtaining the Community versions of the RPM packages:
From the MySQL software repositories, for the following platforms:
For EL5, EL6, or EL7-based platforms and Fedora 21, 22 or 23, use the MySQL Yum repository (see Section
2.5.1, “Installing MySQL on Linux Using the MySQL Yum Repository” for details).
For SUSE Enterprise Linux Server, use the MySQL SLES repository (see Section
2.5.4, “Installing MySQL on Linux Using the MySQL SLES Repository” for details).
From the MySQL Downloads page in the MySQL
Developer Zone, which provides RPM packages that work for different platforms.
The
discussion in this section applies only to the RPM packages downloaded from the MySQL Developer Zone. Installations created with these packages result in files under the system directories shown in the following table.
Table 2.6 MySQL Installation Layout for Linux RPM Packages from the MySQL Developer Zone
Directory | Contents of Directory |
---|---|
/usr/bin | Client programs and scripts |
/usr/sbin | The mysqld server |
/var/lib/mysql | Log files, databases |
/usr/share/info | MySQL manual in Info format |
/usr/share/man | Unix manual pages |
/usr/include/mysql | Include (header) files |
/usr/lib/mysql | Libraries |
/usr/share/mysql | Miscellaneous support files, including error messages, character set files, sample configuration files, SQL for database installation |
RPM distributions of MySQL are also provided by other vendors. Be aware that they may differ from those built by Oracle in features, capabilities, and conventions (including communication setup), and that the instructions in this manual do not necessarily apply
to installing them. The vendor's instructions should be consulted instead. Because of these differences, RPM packages built by Oracle check whether such RPMs built by other vendors are installed. If so, the RPM does not install and produces a message explaining
this.
Conflicts can arise when an RPM from another vendor is already installed, such as when a vendor's conventions about which files belong with the server and which belong with the client library differ from the breakdown used for Oracle packages. In such cases,
attempts to install an Oracle RPM with rpm
-i may result in messages that files in the RPM to be installed conflict with files from an installed package (denoted
mysql-libsin
the following paragraphs).
Each MySQL release provides a
MySQL-shared-compatpackage
that is meant to replace
mysql-libsand provides a replacement-compatible
client library for older MySQL series.
MySQL-shared-compatis set
up to make
mysql-libsobsolete,
but rpm explicitly
refuses to replace obsoleted packages when invoked with
-i(unlike
-U),
which is why installation with rpm
-i produces a conflict.
MySQL-shared-compatcan safely be installed alongside
mysql-libsbecause
libraries are installed to different locations. Therefore, it is possible to install
MySQL-shared-compatfirst,
then manually remove
mysql-libsbefore continuing with
the installation. After
mysql-libsis removed, the
dynamic linker stops looking for the client library in the location where
mysql-libsputs
it, and the library provided by the
MySQL-shared-compatpackage
takes over.
Another alternative is to install packages using yum.
In a directory containing all RPM packages for a MySQL release, yum
install MySQL*rpm installs them in the correct order and removes
mysql-libsin
one step without conflicts.
In most cases, you need install only the
MySQL-serverand
MySQL-clientpackages
to get a functional standard MySQL installation. The other packages are not required for a standard installation.
As of MySQL 5.7.4, MySQL deployments installed using RPM packages are secure by default and have these characteristics:
The installation process creates a single
rootaccount,
'root'@'localhost',
automatically generates an initial random password for this account, and marks the password expired.
For MySQL 5.7.6 and up, the initial random
rootpassword
is written to the error log. For MySQL 5.7.4 and 5.7.5, the password is written to the
.mysql_secretfile
in the directory named by the
HOMEenvironment variable.
Depending on operating system, using a command such as sudo may
cause the value of
HOMEto refer to the home directory
of the
rootsystem user.
.mysql_secretis
created with mode 600 to be accessible only to the system user for whom it is created. (The version differences occur because the data directory and
rootaccount
are initialized using mysqld
--initialize as of 5.7.6 and using mysql_install_db before
5.7.6.)
No anonymous-user MySQL accounts are created.
No
testdatabase is created.
As a result of these actions, it is necessary after installation to start the server, connect as
rootusing
the initial random password, and select a new
rootpassword.
Until this is done,
rootcannot do anything else. To
change the password, you can use the
ALTER USERstatement (for example, with the mysql client).
After resetting the password, remove the
.mysql_secretfile
if one was created; otherwise, if you runmysql_secure_installation,
that command may see the file and expire the
rootpassword
again as part of ensuring secure deployment.
Before MySQL 5.7.4, new RPM install operations produce deployment characteristics similar to MySQL 5.7.4 and up, except that multiple
rootaccounts
may be created, and the
testdatabase is created.
For upgrades, if your installation was originally produced by installing multiple RPM packages, it is best to upgrade all the installed packages, not just some. For example, if you previously installed the server and client RPMs, do not upgrade just the server
RPM.
If the data directory exists at RPM installation time, the installation process does not modify existing data. This has the effect, for example, that accounts in the grant tables are not initialized to the default set of accounts.
If you get a dependency failure when trying to install MySQL packages (for example,
error: removing these packages would break dependencies: libmysqlclient.so.10 is needed by ...), you should also install the
MySQL-shared-compatpackage,
which includes the shared libraries for older releases for backward compatibility.<<< 缺少依赖的包,可以按照官方文档说的直接安装MySQL-shared-compat包即可。
The following list shows the available RPM packages. The names shown here use a suffix of
.linux_glibc2.5.i386.rpm,
but particular packages can have different suffixes, described later. If you plan to install multiple RPM packages, you may wish to download the RPM Bundle tarfile
instead, which contains multiple RPM packages so that you need not download them separately.<<< 对于我来说,下载的是bundle,全部安装。
MySQL-server-VERSION
.linux_glibc2.5.i386.rpmThe MySQL server. You need this unless you only want to connect to a MySQL server running on another machine.
MySQL-client-VERSION
.linux_glibc2.5.i386.rpmThe standard MySQL client programs. You probably always want to install this package.
MySQL-devel-VERSION
.linux_glibc2.5.i386.rpmThe libraries and include files needed to compile other MySQL clients, such as the Perl MySQL module. Install this RPM if you intend to compile C API applications.
MySQL-shared-VERSION
.linux_glibc2.5.i386.rpmThis package contains the shared libraries (
libmysqlclient.so*)
that certain languages and applications need to dynamically load and use MySQL. It contains single-threaded and thread-safe libraries. Install this RPM if you intend to compile or run C API applications that depend on the shared client library.
MySQL-shared-compat-VERSION
.linux_glibc2.5.i386.rpmThis package includes the shared libraries for older releases, but not the libraries for the current release. It contains single-threaded and thread-safe libraries. Install this package if you have applications installed that are dynamically linked against
older versions of MySQL but you want to upgrade to the current version without breaking the library dependencies.
The
MySQL-shared-compatRPM package enables users of
Red Hat-provided
mysql-*-5.1RPM packages to migrate
to Oracle-provided
MySQL-*-5.5packages.
MySQL-shared-compatreplaces
the Red Hat
mysql-libspackage by replacing
libmysqlclient.sofiles
of the latter package, thus satisfying dependencies of other packages on
mysql-libs.
This change affects only users of Red Hat (or Red Hat-compatible) RPM packages. Nothing is different for users of Oracle RPM packages.
MySQL-embedded-VERSION
.linux_glibc2.5.i386.rpmThe embedded MySQL server library.
MySQL-test-VERSION
.linux_glibc2.5.i386.rpmThis package includes the MySQL test suite.
MySQL-VERSION
.src.rpmThis contains the source code for all of the previous packages. It can also be used to rebuild the RPMs on other architectures (for example, Alpha or SPARC).
In RPM package names, the suffix (following the
VERSIONvalue)
has the following syntax:
.[code]PLATFORM.
CPU.rpm
[/code]
The
PLATFORMand
CPUvalues
indicate the type of system for which the package is built.
PLATFORMindicates
the platform and
CPUindicates
the processor type or family.
All packages are dynamically linked against
glibc2.5.
The
PLATFORMvalue
indicates whether the package is platform independent or intended for a specific platform, as shown in the following table.
Table 2.7 MySQL Linux RPM Package Platforms
PLATFORMValue | Intended Use |
---|---|
linux_glibc25 | Platform independent, should run on any Linux distribution that supports glibc2.5 |
rhel5, rhel6 | Red Hat Enterprise Linux 5 or 6 |
el6, el7 | Enterprise Linux 6 or 7 |
sles10, sles11 | SUSE Linux Enterprise Server 10 or 11 |
CPUvalue
indicates the processor type or family for which the package is built, as shown in the following table.
Table 2.8 MySQL Linux RPM Package CPU Identifiers
CPUValue | Intended Processor Type or Family |
---|---|
i386, i586, i686 | Pentium processor or better, 32 bit |
x86_64 | 64-bit x86 processor |
ia64 | Itanium (IA-64) processor |
MySQL-serverRPM),
run a command like this (modify the platform and CPU identifiers appropriately for your system):
shell> [code]rpm -qpl MySQL-server-VERSION
.linux_glibc2.5.i386.rpm[/code]
To perform a standard minimal installation, install the server and client RPMs:
shell> [code]rpm -i MySQL-server-VERSION
.linux_glibc2.5.i386.rpmshell>
rpm -i MySQL-client-VERSION
.linux_glibc2.5.i386.rpm[/code]
To install only the client programs, install just the client RPM:
shell> [code]rpm -i MySQL-client-VERSION
.linux_glibc2.5.i386.rpm[/code]
RPM provides a feature to verify the integrity and authenticity of packages before installing them. To learn more about this feature, see Section
2.1.3, “Verifying Package Integrity Using MD5 Checksums or GnuPG”.
The server RPM places data under the
/var/lib/mysqldirectory.
The RPM also creates a login account for a user named
mysql(if
one does not exist) to use for running the MySQL server, and creates the appropriate entries in
/etc/init.d/to
start the server automatically at boot time. (This means that if you have performed a previous installation and have made changes to its startup script, you may want to make a copy of the script so that you can reinstall it after you install a newer RPM.)
See Section
2.10.5, “Starting and Stopping MySQL Automatically”, for more information on how MySQL can be started automatically on system startup.
For a new installation using RPM packages, the server boot scripts are installed, but the MySQL server is not started at the end of the installation, since the status of the server during an unattended installation is not known.
For an upgrade installation using RPM packages, if the MySQL server is running when the upgrade occurs, the MySQL server is stopped, the upgrade occurs, and the MySQL server is restarted. If the MySQL server is not already running when the RPM upgrade occurs,
the MySQL server is not started at the end of the installation.
Note
Upgrading from a community version to a commercial version of MySQL requires that you first uninstall the community version and then install the commercial version. In this case, you must restart the server manually after the upgrade.
If something goes wrong, you can find more information in the binary installation section. See Section
2.2, “Installing MySQL on Unix/Linux Using Generic Binaries”.
Note
Before MySQL 5.7.4, the accounts 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 Section
2.10, “Postinstallation Setup and Testing”.
An RPM installation creates a user named
mysqland a
group named
mysqlon the system using the useradd, groupadd,
and usermodcommands.
Those commands require appropriate administrative privileges, which is required for locally managed users and groups (as listed in the
/etc/passwdand
/etc/groupfiles)
by the RPM installation process being run by
root.
If you log in as the
mysqluser, you may find that MySQL
displays “Invalid
(old?) table or database name” errors that mention
.mysqlgui,
lost+found,
.mysqlgui,
.bash_history,
.fonts.cache-1,
.lesshst,
.mysql_history,
.profile,
.viminfo,
and similar files created by MySQL or operating system utilities. You can safely ignore these error messages or remove the files or directories that cause them if you do not need them.
For nonlocal user management (LDAP, NIS, and so forth), the administrative tools may require additional authentication (such as a password), and will fail if the installing user does not provide this authentication. Even if they fail, the RPM installation will
not abort but succeed, and this is intentional. If they failed, some of the intended transfer of ownership may be missing, and it is recommended that the system administrator then manually ensures some appropriate user and group exists and manually transfers
ownership following the actions in the RPM spec file.
In MySQL 5.7.2, the RPM spec file has been updated, which has the following consequences:
For a non-upgrade installation (no existing MySQL version installed), it possible to install MySQL using yum.
For upgrades, it is necessary to clean up any earlier MySQL installations. In effect, the update is performed by removing the old installations and installing the new one.
Additional details follow.
For a non-upgrade installation of MySQL 5.7.2 or later, it is possible to install using yum:
shell> [code]yum install MySQL-server-NEWVERSION
.linux_glibc2.5.i386.rpm[/code]
For upgrades to MySQL 5.7.2 or later, perform the upgrade by removing the old installation and installing the new one:
Remove the existing 5.7.
Xinstallation.
OLDVERSIONis
the version to remove.
shell> [code]rpm -e MySQL-server-OLDVERSION
.linux_glibc2.5.i386.rpm[/code]
Repeat this step for all installed MySQL RPMs.
Install the new version.
NEWVERSIONis
the version to install.
shell> [code]rpm -ivh MySQL-server-NEWVERSION
.linux_glibc2.5.i386.rpm[/code]
Alternatively, the removal and installation can be done using yum:
shell> [code]yum remove MySQL-server-OLDVERSION
.linux_glibc2.5.i386.rpmshell>
yum install MySQL-server-NEWVERSION
.linux_glibc2.5.i386.rpm[/code]
相关文章推荐
- linux or unix vi编辑器常用命令
- linux下验证码无法显示:Could not initialize class sun.awt.X1 解决方案
- Linux设置和查看环境变量的方法
- KVM虚拟化基本管理
- linux下通过命令行更新android sdk
- Linux NPTL 是什么
- Linux上安装JDK环境变量配置
- Linux多线程实践(8) --Posix条件变量解决生产者消费者问题
- linux设置外接显示器的分辨率
- Linux下高cpu解决方案
- linux java so 历险
- linux 命令
- linux防止ssh远程暴力破解的方法和fail2ban软件的配置应用
- Linux进程间通信(IPC)编程实践(四) 详解System V消息队列(2)(msgsnd & msgrcv)
- Linux GPIO驱动 - 驱动框架概述
- linux: 可重入函数与不可重入函数
- 在Linux(CentOS)下,AAPT解析APK指令报错少库
- Linux内核IP Queue机制的分析(一) 2011-10-13 22:17:40
- Linux内核IP Queue机制的分析(一)——用户态接收数据包
- Linux工作实用命令技巧