查看: 1811|回复: 0

centos7 安装 mysql

[复制链接]

37

主题

73

帖子

7676

积分

管理员

Rank: 64Rank: 64Rank: 64Rank: 64

积分
7676
发表于 2016-8-24 16:26:57 | 显示全部楼层 |阅读模式
本帖最后由 dongfei 于 2016-8-24 16:29 编辑

Installing MySQL on Linux Using the MySQL YumRepository

MySQLprovides a Yum-style software repository for the following Linux platforms:
·        EL5, EL6, and EL7-basedplatforms (for example, the corresponding versions of Red Hat Enterprise Linux,Oracle Linux, and CentOS)
·        Fedora 23 and 24
Currently, the MySQL Yum repository for the above-mentioned platformsprovides RPM packages for installing the MySQL server, client, MySQL Workbench,MySQL Utilities, Connector/ODBC, and Connector/Python (not all packages areavailable for all the platforms; see InstallingAdditional MySQL Products and Components with Yum fordetails).
Before You Start
As a popular, open-source software, MySQL,in its original or re-packaged form, is widely installed on many systems fromvarious sources, including different software download sites, softwarerepositories, and so on. The following instructions assume that MySQL is notalready installed on your system using a third-party-distributed RPM package;if that is not the case, follow the instructions given in Section 2.11.1.2,“Upgrading MySQL with the MySQL Yum Repository” or Section 2.5.2,“Replacing a Third-Party Distribution of MySQL Using the MySQL Yum Repository”.
Steps for a Fresh Installation of MySQL
Followthe steps below to install the latest GA version of MySQL with the MySQL Yumrepository:
1.   Adding the MySQL Yum Repository
First, add the MySQL Yumrepository to your system's repository list. This is a one-time operation,which can be performed by installing an RPM provided by MySQL. Follow thesesteps:
a.    Go to the Download MySQL YumRepository page (http://dev.mysql.com/downloads/repo/yum/)in the MySQL Developer Zone.
b.   Select and download the releasepackage for your platform.
c.    Install the downloaded releasepackage with the following command (except for EL5-based systems), replacingplatform-and-version-specific-package-name withthe name of the downloaded RPM package:
d. shell> sudo yum localinstall platform-and-version-specific-package-name.rpm
For an EL6-based system, thecommand is in the form of:
shell> sudo yum localinstall mysql57-community-release-el6-{version-number}.noarch.rpm
For an EL7-based system:
shell> sudo yum localinstall mysql57-community-release-el7-{version-number}.noarch.rpm
For Fedora 23:
shell> sudo dnf install mysql57-community-release-fc23-{version-number}.noarch.rpm
For Fedora 24:
shell> sudo dnf install mysql57-community-release-fc24-{version-number}.noarch.rpm
For an EL5-based system, usethe following command instead:
shell> sudo rpm -Uvh mysql57-community-release-el5-{version-number}.noarch.rpm
Theinstallation command adds the MySQL Yum repository to your system's repositorylist and downloads the GnuPG key to check the integrity of the softwarepackages. See Section 2.1.3.2,“Signature Checking Using GnuPG” fordetails on GnuPG key checking.
You cancheck that the MySQL Yum repository has been successfully added by thefollowing command (for dnf-enabled systems, replace yum in the command with dnf):
shell> yum repolist enabled | grep "mysql.*-community.*"
Note
Oncethe MySQL Yum repository is enabled on your system, any system-wide update bythe yum update command (or dnfupgrade fordnf-enabled systems) will upgrade MySQL packages on your system and alsoreplace any native third-party packages, if Yum finds replacements for them inthe MySQL Yum repository; see Section 2.11.1.2,“Upgrading MySQL with the MySQL Yum Repository”and,for a discussion on some possible effects of that on your system, see Upgrading the Shared ClientLibraries.
2.   Selecting a Release Series
Whenusing the MySQL Yum repository, the latest GA series (currently MySQL 5.7) isselected for installation by default. If this is what you want, you can skip tothe next step, Installing MySQL.
Withinthe MySQL Yum repository, different release series of the MySQL CommunityServer are hosted in different subrepositories. The subrepository for thelatest GA series (currently MySQL 5.7) is enabled by default, and thesubrepositories for all other series (for example, the MySQL 5.6 series) aredisabled by default. Use this command to see all the subrepositories in theMySQL Yum repository, and see which of them are enabled or disabled (fordnf-enabled systems, replace yum in the command with dnf):
shell> yum repolist all | grep mysql
Toinstall the latest release from the latest GA series, no configuration isneeded. To install the latest release from a specific series other than thelatest GA series, disable the subrepository for the latest GA series and enablethe subrepository for the specific series before running the installationcommand. If your platform supports yum-config-manager,you can do that by issuing these commands, which disable the subrepository forthe 5.7 series and enable the one for the 5.6 series:
shell> sudo yum-config-manager --disable mysql57-communityshell> sudo yum-config-manager --enable mysql56-community
For dnf-enabled platforms:
shell> sudo dnf config-manager --disable mysql57-communityshell> sudo dnf config-manager --enable mysql56-community
Besidesusing yum-config-manager or the dnfconfig-manager command,you can also select a release series by editing manually the /etc/yum.repos.d/mysql-community.repo file.This is a typical entry for a release series' subrepository in the file:
[mysql57-community]name=MySQL 5.7 Community Serverbaseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/6/$basearch/enabled=1gpgcheck=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Findthe entry for the subrepository you want to configure, and edit the enabled option.Specify enabled=0 todisable a subrepository, or enabled=1 toenable a subrepository. For example, to install MySQL 5.6, make sure you haveenabled=0 forthe above subrepository entry for MySQL 5.7, and have enabled=1 forthe entry for the 5.6 series:
# Enable to use MySQL 5.6[mysql56-community]name=MySQL 5.6 Community Serverbaseurl=http://repo.mysql.com/yum/mysql-5.6-community/el/6/$basearch/enabled=1gpgcheck=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
You should only enablesubrepository for one release series at any time. When subrepositories for morethan one release series are enabled, the latest series will be used by Yum.
Verifythat the correct subrepositories have been enabled and disabled by running thefollowing command and checking its output (for dnf-enabled systems, replace yum in the command with dnf):
shell> yum repolist enabled | grep mysql
3.   Installing MySQL
InstallMySQL by the following command (for dnf-enabled systems, replace yum in the command with dnf):
shell> sudo yum install mysql-community-server
Thisinstalls the package for MySQL server (mysql-community-server)and also packages for the components required to run the server, includingpackages for the client (mysql-community-client),the common error messages and character sets for client and server (mysql-community-common),and the shared client libraries (mysql-community-libs).
4.   Starting the MySQL Server
Start the MySQL server with thefollowing command:
shell> sudo service mysqld startStarting mysqld:[ OK ]
You can check the status of theMySQL server with the following command:
shell> sudo service mysqld statusmysqld (pid 3066) is running.
Atthe initial start up of the server, the following happens, given that the datadirectory of the server is empty:
·        The server is initialized.
·        An SSL certificate and keyfiles are generated in the data directory.
·        The validate_passwordplugin is installedand enabled.
·        A superuser account 'root'@'localhost iscreated. A password for the superuser is set and stored in the error log file.To reveal it, use the following command:
·         shell> sudo grep 'temporary password' /var/log/mysqld.log
Change the root password assoon as possible by logging in with the generated, temporary password and set acustom password for the superuser account:
shell> mysql -uroot -p mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';
Note
MySQL's validate_password plugin is installed by default. Thiswill require that passwords contain at least one upper case letter, one lowercase letter, one digit, and one special character, and that the total passwordlength is at least 8 characters.
For more information on the postinstallationprocedures, see Section 2.10,“Postinstallation Setup and Testing”.
Note
Compatibility Information forEL7-based platforms: Thefollowing RPM packages from the native software repositories of the platformsare incompatible with the package from the MySQL Yum repository that installsthe MySQL server. Once you have installed MySQL using the MySQL Yum repository,you will not be able to install these packages (and vice versa).
·        akonadi-mysql

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

快速回复 返回顶部 返回列表