Oracle linux ��������� mysql
MySQL 8.0 Reference Manual Including MySQL NDB Cluster 8.0
2.5.4В Installing MySQL on Linux Using RPM Packages from Oracle
The recommended way to install MySQL on RPM-based Linux distributions is by using the RPM packages provided by Oracle. There are two sources for obtaining them, for the Community Edition of MySQL:
From the MySQL software repositories:
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 installation instructions in this manual do not necessarily apply to them. The vendor’s instructions should be consulted instead.
MySQL RPM Packages
TableВ 2.9В RPM Packages for MySQL Community Edition
Package Name | Summary |
---|---|
mysql-community-client | MySQL client applications and tools |
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-embedded-compat | MySQL server as an embedded library with compatibility for applications using version 18 of the library |
mysql-community-libs | Shared libraries for MySQL database client applications |
mysql-community-libs-compat | Shared compatibility libraries for previous MySQL installations |
mysql-community-server | Database server and related tools |
mysql-community-server-debug | Debug server and plugin binaries |
mysql-community-test | Test suite for the MySQL server |
mysql-community | The source code RPM looks similar to mysql-community-8.0.26-1.el7.src.rpm, depending on selected OS |
Additional *debuginfo* RPMs | There are several debuginfo packages: mysql-community-client-debuginfo, mysql-community-libs-debuginfo mysql-community-server-debug-debuginfo mysql-community-server-debuginfo, and mysql-community-test-debuginfo. |
TableВ 2.10В RPM Packages for the MySQL Enterprise Edition
Package Name | Summary |
---|---|
mysql-commercial-backup | MySQL Enterprise Backup (added in 8.0.11) |
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-embedded-compat | MySQL server as an embedded library with compatibility for applications using version 18 of the library |
mysql-commercial-libs | Shared libraries for MySQL database client applications |
mysql-commercial-libs-compat | Shared 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-server | Database server and related tools |
mysql-commercial-test | Test suite for the MySQL server |
Additional *debuginfo* RPMs | There are several debuginfo packages: mysql-commercial-client-debuginfo, mysql-commercial-libs-debuginfo mysql-commercial-server-debug-debuginfo mysql-commercial-server-debuginfo, and mysql-commercial-test-debuginfo. |
The full names for the RPMs have the following syntax:
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.11В MySQL Linux RPM Package Distribution Identifiers
Distribution Value | Intended Use |
---|---|
el where is the major Enterprise Linux version, such as el8 | EL6, EL7, and EL8-based platforms (for example, the corresponding versions of Oracle Linux, Red Hat Enterprise Linux, and CentOS) |
fc where is the major Fedora version, such as fc34 | Fedora 33 and 34 |
sles12 | SUSE Linux Enterprise Server 12 |
To see all files in an RPM package (for example, mysql-community-server ), use the following command:
The discussion in the rest of this section applies only to an installation process using the RPM packages directly downloaded from Oracle, instead of through a MySQL repository.
Dependency relationships exist among some of the packages. If you plan to install many of the packages, you may wish to download the RPM bundle tar file instead, which contains all the RPM packages listed above, so that you need not download them separately.
In most cases, you need to install the mysql-community-server , mysql-community-client , mysql-community-libs , mysql-community-common , and mysql-community-libs-compat packages to get a functional, standard MySQL installation. To perform such a standard, basic installation, go to the folder that contains all those packages (and, preferably, no other RPM packages with similar names), and issue the following command:
Replace yum with zypper for SLES, and with dnf for Fedora.
While it is much preferable to use a high-level package management tool like yum to install the packages, users who prefer direct rpm commands can replace the yum install command with the rpm -Uvh command; however, using rpm -Uvh instead makes the installation process more prone to failure, due to potential dependency issues the installation process might run into.
To install only the client programs, you can skip mysql-community-server in your list of packages to install; issue the following command:
Replace yum with zypper for SLES, and with dnf for Fedora.
A standard installation of MySQL using the RPM packages result in files and resources created under the system directories, shown in the following table.
TableВ 2.12В 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 | |
Value of secure_file_priv | /var/lib/mysql-files |
System V init script | |
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 |
The installation also creates a user named mysql and a group named mysql on the system.
Installation of previous versions of MySQL using older packages might have created a configuration file named /usr/my.cnf . It is highly recommended that you examine the contents of the file and migrate the desired settings inside to the file /etc/my.cnf file, then remove /usr/my.cnf .
MySQL is NOT automatically started at the end of the installation process. For Red Hat Enterprise Linux, Oracle Linux, CentOS, and Fedora systems, use the following command to start MySQL:
For SLES systems, the command is the same, but the service name is different:
If the operating system is systemd enabled, standard systemctl (or alternatively, service with the arguments reversed) commands such as stop , start , status , and restart should be used to manage the MySQL server service. The mysqld service is enabled by default, and it starts at system reboot. Notice that certain things might work differently on systemd platforms: for example, changing the location of the data directory might cause issues. See Section 2.5.9, “Managing MySQL Server with systemd” for additional information.
During an upgrade installation using RPM and DEB packages, if the MySQL server is running when the upgrade occurs then the MySQL server is stopped, the upgrade occurs, and the MySQL server is restarted. One exception: if the edition also changes during an upgrade (such as community to commercial, or vice-versa), then MySQL server is not restarted.
At the initial start up of the server, the following happens, given that the data directory of the server is empty:
The server is initialized.
An SSL certificate and key files are generated in the data directory.
validate_password is installed and enabled.
A superuser account ‘root’@’localhost’ is created. A password for the superuser is set and stored in the error log file. To reveal it, use the following command for RHEL, Oracle Linux, CentOS, and Fedora systems:
Use the following command for SLES systems:
The next step is to log in with the generated, temporary password and set a custom password for the superuser account:
validate_password is installed by default. The default password policy implemented by validate_password requires that passwords contain at least one uppercase letter, one lowercase letter, one digit, and one special character, and that the total password length is at least 8 characters.
If something goes wrong during installation, you might find debug information in the error log file /var/log/mysqld.log .
For some Linux distributions, it might be necessary to increase the limit on number of file descriptors available to mysqld . See Section B.3.2.16, “File Not Found and Similar Errors”
Installing Client Libraries from Multiple MySQL Versions.В It is possible to install multiple client library versions, such as for the case that you want to maintain compatibility with older applications linked against previous libraries. To install an older client library, use the —oldpackage option with rpm . For example, to install mysql-community-libs-5.5 on an EL6 system that has libmysqlclient.21 from MySQL 8.0, use a command like this:
Debug Package. A special variant of MySQL Server compiled with the debug package has been included in the server RPM packages. It performs debugging and memory allocation checks and produces a trace file when the server is running. To use that debug version, start MySQL with /usr/sbin/mysqld-debug , instead of starting it as a service or with /usr/sbin/mysqld . See Section 5.9.4, “The DBUG Package” for the debug options you can use.
The default plugin directory for debug builds changed from /usr/lib64/mysql/plugin to /usr/lib64/mysql/plugin/debug in MySQL 8.0.4. Previously, it was necessary to change plugin_dir to /usr/lib64/mysql/plugin/debug for debug builds.
Rebuilding RPMs from source SRPMs.В Source code SRPM packages for MySQL are available for download. They can be used as-is to rebuild the MySQL RPMs with the standard rpmbuild tool chain.
Источник
MySQL : Installation on Linux
This article gives examples of installing MySQL on both Oracle Linux 6 (RHEL6/CentOS6) and Oracle Linux 7 (RHEL7/CentOS7). It also includes examples of MySQL 5.6 and 5.7 installations. Pick the combination that you need.
Installation
If you want to run the most recent versions, you can use the MySQL Yum repository available here. Download and install the repository package.
With the repository in place, you can install the latest version using the same command shown previously.
If you want MySQL Workbench, issue the following installation command.
If you don’t need the latest MySQL version, you can use the version present in the regular RHEL/Oracle Linux distribution.
Start the MySQL Service (mysqld)
Make sure the mysqld service is set to start on reboot and start the service. On startup the service will prompt you with information on how to secure the installation. The example below is based on an installation on Oracle Linux 6.
If you are using Oracle Linux 7, you will need to perform the following.
Basic Configuration
Make sure SELinux is running in permissive mode, so you can change the locations of the MySQL files.
Make the setting permanent, by editing the «/etc/selinux/config» file, setting the following value.
Create directories to hold data and binary logs.
Stop the mysqld service.
Edit the «/etc/my.cnf» file, setting the following values in the «[mysqld]» section. Be sure to reflect any path changes you require in these settings.
Start the mysqld service.
Secure the Installation
As suggested by the startup output, run the «/usr/bin/mysql_secure_installation» script to secure the installation. The process is a little different if you are using MySQL 5.7 compared to previous versions. First, let’s take a look at securing MySQL 5.6. Hit return when prompted for the root password and pick all the default options.
If you are securing MySQL 5.7, there is a random root password defined by default. You can see what it is by issuing the following command.
Once you run the «/usr/bin/mysql_secure_installation» script, you will be asked to supply the root password. Use the password displayed by the previous command. In this version, the default answer to every question is «N», so you will have to explicitly answer «Y/y» for every prompt.
You are now ready to start using MySQL.
There are additional hardening steps you should consider, as described here.
Create Database
The first thing you will probably want to do is create a database. First you must connect to MySQL.
Create a new database using the following command.
You can see the current databases using the following command.
To switch between databases using the following command.
You can make new connections directly to the database as follows.
SELinux
If you are using SELinux in «enforcing» mode on the server, moving the datadir and log_bin directories can cause SELinux to complain. You will either need to set it to permissive, explained here, or put the correct policies in place.
Policies already in place due to default installation.
The following policies will need to be applied if you’ve altered the datadir and log_bin directories.
Источник