YUM方式安装MYSQL5.7
首先mysql官网下载yum源https://dev.mysql.com/downloads/repo/yum/
然后将下载好的rpm文件安装并校验
[root@elegant-snap-3 /stage]$ rpm -ivh mysql80-community-release-el7-2.noarch.rpm warning: mysql80-community-release-el7-2.noarch.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY Preparing... ################################# [100%] Updating / installing... 1:mysql80-community-release-el7-2 ################################# [100%] [root@elegant-snap-3 /stage]$ ls /etc/yum.repos.d/ CentOS-Base.repo CentOS-fasttrack.repo CentOS-Vault.repo epel-testing.repo vscode.repo CentOS-CR.repo CentOS-Media.repo elrepo.repo mysql-community.repo CentOS-Debuginfo.repo CentOS-Sources.repo epel.repo mysql-community-source.repo [root@elegant-snap-3 /stage]$ yum list|grep mysql mysql80-community-release.noarch el7-2 installed akonadi-mysql.x86_64 1.9.2-4.el7 base apr-util-mysql.x86_64 1.5.2-6.el7 base dovecot-mysql.x86_64 1:2.2.36-3.el7 base freeradius-mysql.x86_64 3.0.13-9.el7_5 base libdbi-dbd-mysql.x86_64 0.8.3-16.el7 base mysql-community-client.i686 8.0.15-1.el7 mysql80-community mysql-community-client.x86_64 8.0.15-1.el7 mysql80-community mysql-community-common.i686 8.0.15-1.el7 mysql80-community mysql-community-common.x86_64 8.0.15-1.el7 mysql80-community mysql-community-devel.i686 8.0.15-1.el7 mysql80-community mysql-community-devel.x86_64 8.0.15-1.el7 mysql80-community mysql-community-embedded-compat.i686 8.0.15-1.el7 mysql80-community mysql-community-embedded-compat.x86_64 8.0.15-1.el7 mysql80-community mysql-community-libs.i686 8.0.15-1.el7 mysql80-community mysql-community-libs.x86_64 8.0.15-1.el7 mysql80-community mysql-community-libs-compat.i686 8.0.15-1.el7 mysql80-community mysql-community-libs-compat.x86_64 8.0.15-1.el7 mysql80-community mysql-community-release.noarch el7-5 mysql-connectors-community mysql-community-server.x86_64 8.0.15-1.el7 mysql80-community mysql-community-test.x86_64 8.0.15-1.el7 mysql80-community mysql-connector-c++.x86_64 8.0.15-1.el7 mysql-connectors-community mysql-connector-c++-devel.x86_64 8.0.15-1.el7 mysql-connectors-community mysql-connector-c++-jdbc.x86_64 8.0.15-1.el7 mysql-connectors-community mysql-connector-java.noarch 1:5.1.25-3.el7 base mysql-connector-odbc.x86_64 8.0.15-1.el7 mysql-connectors-community mysql-connector-odbc-debuginfo.x86_64 8.0.15-1.el7 mysql-connectors-community mysql-connector-odbc-setup.x86_64 8.0.15-1.el7 mysql-connectors-community mysql-connector-python.noarch 2.0.4-1.el7 mysql-connectors-community mysql-connector-python.x86_64 8.0.15-1.el7 mysql-connectors-community mysql-connector-python-cext.x86_64 8.0.15-1.el7 mysql-connectors-community mysql-connector-python-debuginfo.x86_64 2.1.7-1.el7 mysql-connectors-community mysql-ref-manual-8.0-en-html-chapter.noarch 1-20190127 mysql80-community mysql-ref-manual-8.0-en-pdf.noarch 1-20190127 mysql80-community mysql-router.x86_64 8.0.12-1.el7 mysql-tools-community mysql-router-community.x86_64 8.0.15-1.el7 mysql-tools-community mysql-router-debuginfo.x86_64 8.0.12-1.el7 mysql-tools-community mysql-shell.x86_64 8.0.15-1.el7 mysql-tools-community mysql-shell-debuginfo.x86_64 8.0.15-1.el7 mysql-tools-community mysql-utilities.noarch 1.6.5-1.el7 mysql-tools-community mysql-utilities-extra.noarch 1.5.6-1.el7 mysql-tools-community mysql-workbench-community.x86_64 8.0.15-1.el7 mysql-tools-community mysql-workbench-community-debuginfo.x86_64 8.0.15-1.el7 mysql-tools-community pcp-pmda-mysql.x86_64 4.1.0-5.el7_6 updates php-mysql.x86_64 5.4.16-46.el7 base php-mysqlnd.x86_64 5.4.16-46.el7 base qt-mysql.i686 1:4.8.7-2.el7 base qt-mysql.x86_64 1:4.8.7-2.el7 base qt5-qtbase-mysql.i686 5.9.2-3.el7 base qt5-qtbase-mysql.x86_64 5.9.2-3.el7 base redland-mysql.x86_64 1.0.16-6.el7 base rsyslog-mysql.x86_64 8.24.0-34.el7 base [root@elegant-snap-3 /stage]$ yum repolist all |grep mysql mysql-cluster-7.5-community/x86_64 MySQL Cluster 7.5 Community disabled mysql-cluster-7.5-community-source MySQL Cluster 7.5 Community disabled mysql-cluster-7.6-community/x86_64 MySQL Cluster 7.6 Community disabled mysql-cluster-7.6-community-source MySQL Cluster 7.6 Community disabled mysql-connectors-community/x86_64 MySQL Connectors Community enabled: 95 mysql-connectors-community-source MySQL Connectors Community disabled mysql-tools-community/x86_64 MySQL Tools Community enabled: 84 mysql-tools-community-source MySQL Tools Community - Sou disabled mysql-tools-preview/x86_64 MySQL Tools Preview disabled mysql-tools-preview-source MySQL Tools Preview - Sourc disabled mysql55-community/x86_64 MySQL 5.5 Community Server disabled mysql55-community-source MySQL 5.5 Community Server disabled mysql56-community/x86_64 MySQL 5.6 Community Server disabled mysql56-community-source MySQL 5.6 Community Server disabled mysql57-community/x86_64 MySQL 5.7 Community Server disabled mysql57-community-source MySQL 5.7 Community Server disabled mysql80-community/x86_64 MySQL 8.0 Community Server enabled: 82 mysql80-community-source MySQL 8.0 Community Server disabled [root@elegant-snap-3 /stage]$
默认是最新的mysql8.0源启用,修改为5.7启用8.0禁用
[root@elegant-snap-3 /etc/yum.repos.d]$ yum repolist all|grep mysql mysql-cluster-7.5-community/x86_64 MySQL Cluster 7.5 Community disabled mysql-cluster-7.5-community-source MySQL Cluster 7.5 Community disabled mysql-cluster-7.6-community/x86_64 MySQL Cluster 7.6 Community disabled mysql-cluster-7.6-community-source MySQL Cluster 7.6 Community disabled mysql-connectors-community/x86_64 MySQL Connectors Community enabled: 95 mysql-connectors-community-source MySQL Connectors Community disabled mysql-tools-community/x86_64 MySQL Tools Community enabled: 84 mysql-tools-community-source MySQL Tools Community - Sou disabled mysql-tools-preview/x86_64 MySQL Tools Preview disabled mysql-tools-preview-source MySQL Tools Preview - Sourc disabled mysql55-community/x86_64 MySQL 5.5 Community Server disabled mysql55-community-source MySQL 5.5 Community Server disabled mysql56-community/x86_64 MySQL 5.6 Community Server disabled mysql56-community-source MySQL 5.6 Community Server disabled mysql57-community/x86_64 MySQL 5.7 Community Server enabled: 327 mysql57-community-source MySQL 5.7 Community Server disabled mysql80-community/x86_64 MySQL 8.0 Community Server disabled mysql80-community-source MySQL 8.0 Community Server disabled [root@elegant-snap-3 /etc/yum.repos.d]$
那么mysql5.7的yum源就设置好了直接yum install
[root@elegant-snap-3 /etc/yum.repos.d]$ yum install mysql-community-server Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: repos.lax.quadranet.com * elrepo-kernel: repos.lax-noc.com * extras: repos.lax.quadranet.com * updates: mirror.fileplanet.com Resolving Dependencies --> Running transaction check ---> Package mysql-community-server.x86_64 0:5.7.25-1.el7 will be installed --> Processing Dependency: mysql-community-common(x86-64) = 5.7.25-1.el7 for package: mysql-community-server-5.7.25-1.el7.x86_64 --> Processing Dependency: mysql-community-client(x86-64) >= 5.7.9 for package: mysql-community-server-5.7.25-1.el7.x86_64 --> Processing Dependency: libaio.so.1(LIBAIO_0.4)(64bit) for package: mysql-community-server-5.7.25-1.el7.x86_64 --> Processing Dependency: libaio.so.1(LIBAIO_0.1)(64bit) for package: mysql-community-server-5.7.25-1.el7.x86_64 --> Processing Dependency: libaio.so.1()(64bit) for package: mysql-community-server-5.7.25-1.el7.x86_64 --> Running transaction check ---> Package libaio.x86_64 0:0.3.109-13.el7 will be installed ---> Package mysql-community-client.x86_64 0:5.7.25-1.el7 will be installed --> Processing Dependency: mysql-community-libs(x86-64) >= 5.7.9 for package: mysql-community-client-5.7.25-1.el7.x86_64 ---> Package mysql-community-common.x86_64 0:5.7.25-1.el7 will be installed --> Running transaction check ---> Package mariadb-libs.x86_64 1:5.5.52-1.el7 will be obsoleted --> Processing Dependency: libmysqlclient.so.18()(64bit) for package: 2:postfix-2.10.1-6.el7.x86_64 --> Processing Dependency: libmysqlclient.so.18(libmysqlclient_18)(64bit) for package: 2:postfix-2.10.1-6.el7.x86_64 ---> Package mysql-community-libs.x86_64 0:5.7.25-1.el7 will be obsoleting --> Running transaction check ---> Package mysql-community-libs-compat.x86_64 0:5.7.25-1.el7 will be obsoleting ---> Package postfix.x86_64 2:2.10.1-6.el7 will be updated ---> Package postfix.x86_64 2:2.10.1-7.el7 will be an update --> Processing Dependency: libcrypto.so.10(OPENSSL_1.0.2)(64bit) for package: 2:postfix-2.10.1-7.el7.x86_64 --> Running transaction check ---> Package openssl-libs.x86_64 1:1.0.1e-60.el7 will be updated --> Processing Dependency: openssl-libs(x86-64) = 1:1.0.1e-60.el7 for package: 1:openssl-1.0.1e-60.el7.x86_64 ---> Package openssl-libs.x86_64 1:1.0.2k-16.el7_6.1 will be an update --> Running transaction check ---> Package openssl.x86_64 1:1.0.1e-60.el7 will be updated ---> Package openssl.x86_64 1:1.0.2k-16.el7_6.1 will be an update --> Finished Dependency Resolution Dependencies Resolved =================================================================================================================================== Package Arch Version Repository Size =================================================================================================================================== Installing: mysql-community-libs x86_64 5.7.25-1.el7 mysql57-community 2.2 M replacing mariadb-libs.x86_64 1:5.5.52-1.el7 mysql-community-libs-compat x86_64 5.7.25-1.el7 mysql57-community 2.0 M replacing mariadb-libs.x86_64 1:5.5.52-1.el7 mysql-community-server x86_64 5.7.25-1.el7 mysql57-community 165 M Installing for dependencies: libaio x86_64 0.3.109-13.el7 base 24 k mysql-community-client x86_64 5.7.25-1.el7 mysql57-community 24 M mysql-community-common x86_64 5.7.25-1.el7 mysql57-community 274 k Updating for dependencies: openssl x86_64 1:1.0.2k-16.el7_6.1 updates 493 k openssl-libs x86_64 1:1.0.2k-16.el7_6.1 updates 1.2 M postfix x86_64 2:2.10.1-7.el7 base 2.4 M Transaction Summary =================================================================================================================================== Install 3 Packages (+3 Dependent packages) Upgrade ( 3 Dependent packages) Total download size: 198 M Is this ok [y/d/N]: y Downloading packages: Delta RPMs disabled because /usr/bin/applydeltarpm not installed. (1/9): libaio-0.3.109-13.el7.x86_64.rpm | 24 kB 00:00:00 warning: /var/cache/yum/x86_64/7/mysql57-community/packages/mysql-community-common-5.7.25-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY Public key for mysql-community-common-5.7.25-1.el7.x86_64.rpm is not installed (2/9): mysql-community-common-5.7.25-1.el7.x86_64.rpm | 274 kB 00:00:00 (3/9): mysql-community-libs-5.7.25-1.el7.x86_64.rpm | 2.2 MB 00:00:00 (4/9): mysql-community-libs-compat-5.7.25-1.el7.x86_64.rpm | 2.0 MB 00:00:00 (5/9): mysql-community-client-5.7.25-1.el7.x86_64.rpm | 24 MB 00:00:00 (6/9): postfix-2.10.1-7.el7.x86_64.rpm | 2.4 MB 00:00:00 (7/9): openssl-1.0.2k-16.el7_6.1.x86_64.rpm | 493 kB 00:00:00 (8/9): openssl-libs-1.0.2k-16.el7_6.1.x86_64.rpm | 1.2 MB 00:00:00 (9/9): mysql-community-server-5.7.25-1.el7.x86_64.rpm | 165 MB 00:00:03 ----------------------------------------------------------------------------------------------------------------------------------- Total 54 MB/s | 198 MB 00:00:03 Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql Importing GPG key 0x5072E1F5: Userid : "MySQL Release Engineering @oss.oracle.com="">" Fingerprint: a4a9 4068 76fc bd3c 4567 70c8 8c71 8d3b 5072 e1f5 Package : mysql80-community-release-el7-2.noarch (installed) From : /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql Is this ok [y/N]: y Running transaction check Running transaction test Transaction test succeeded Running transaction Warning: RPMDB altered outside of yum. Updating : 1:openssl-libs-1.0.2k-16.el7_6.1.x86_64 1/13 Installing : mysql-community-common-5.7.25-1.el7.x86_64 2/13 Installing : mysql-community-libs-5.7.25-1.el7.x86_64 3/13 Installing : mysql-community-libs-compat-5.7.25-1.el7.x86_64 4/13 Installing : mysql-community-client-5.7.25-1.el7.x86_64 5/13 Installing : libaio-0.3.109-13.el7.x86_64 6/13 Installing : mysql-community-server-5.7.25-1.el7.x86_64 7/13 Updating : 2:postfix-2.10.1-7.el7.x86_64 8/13 Updating : 1:openssl-1.0.2k-16.el7_6.1.x86_64 9/13 Cleanup : 2:postfix-2.10.1-6.el7.x86_64 10/13 Erasing : 1:mariadb-libs-5.5.52-1.el7.x86_64 11/13 Cleanup : 1:openssl-1.0.1e-60.el7.x86_64 12/13 Cleanup : 1:openssl-libs-1.0.1e-60.el7.x86_64 13/13 Verifying : mysql-community-libs-5.7.25-1.el7.x86_64 1/13 Verifying : 1:openssl-1.0.2k-16.el7_6.1.x86_64 2/13 Verifying : mysql-community-libs-compat-5.7.25-1.el7.x86_64 3/13 Verifying : mysql-community-common-5.7.25-1.el7.x86_64 4/13 Verifying : 2:postfix-2.10.1-7.el7.x86_64 5/13 Verifying : mysql-community-client-5.7.25-1.el7.x86_64 6/13 Verifying : 1:openssl-libs-1.0.2k-16.el7_6.1.x86_64 7/13 Verifying : mysql-community-server-5.7.25-1.el7.x86_64 8/13 Verifying : libaio-0.3.109-13.el7.x86_64 9/13 Verifying : 1:openssl-libs-1.0.1e-60.el7.x86_64 10/13 Verifying : 1:mariadb-libs-5.5.52-1.el7.x86_64 11/13 Verifying : 2:postfix-2.10.1-6.el7.x86_64 12/13 Verifying : 1:openssl-1.0.1e-60.el7.x86_64 13/13 Installed: mysql-community-libs.x86_64 0:5.7.25-1.el7 mysql-community-libs-compat.x86_64 0:5.7.25-1.el7 mysql-community-server.x86_64 0:5.7.25-1.el7 Dependency Installed: libaio.x86_64 0:0.3.109-13.el7 mysql-community-client.x86_64 0:5.7.25-1.el7 mysql-community-common.x86_64 0:5.7.25-1.el7 Dependency Updated: openssl.x86_64 1:1.0.2k-16.el7_6.1 openssl-libs.x86_64 1:1.0.2k-16.el7_6.1 postfix.x86_64 2:2.10.1-7.el7 Replaced: mariadb-libs.x86_64 1:5.5.52-1.el7 Complete!
启动mysql
[root@elegant-snap-3 /etc/yum.repos.d]$ systemctl start mysqld.service [root@elegant-snap-3 /etc/yum.repos.d]$ systemctl status mysqld.service ● mysqld.service - MySQL Server Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled) Active: active (running) since Sat 2019-04-20 22:48:51 EDT; 3s ago Docs: man:mysqld(8) http://dev.mysql.com/doc/refman/en/using-systemd.html Process: 29727 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=0/SUCCESS) Process: 29709 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS) Main PID: 29730 (mysqld) CGroup: /system.slice/mysqld.service └─29730 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid Apr 20 22:48:50 elegant-snap-3.localdomain systemd[1]: Starting MySQL Server... Apr 20 22:48:51 elegant-snap-3.localdomain systemd[1]: Started MySQL Server. [root@elegant-snap-3 /etc/yum.repos.d]$
从日志文件获取临时密码并改密码,由于测试环境密码设置简单不通过密码复杂度要修改下密码策略
[root@elegant-snap-3 /etc/yum.repos.d]$ grep 'temporary password' /var/log/mysqld.log 2019-04-21T02:45:29.945179Z 1 [Note] A temporary password is generated for root@localhost: uxEQfR:,i4lp [root@elegant-snap-3 /etc/yum.repos.d]$ mysql -uroot -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.7.25 Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> alter user 'root'@'localhost' identified by 'mysql'; ERROR 1819 (HY000): Your password does not satisfy the current policy requirements mysql> set global validate_password_length=4; Query OK, 0 rows affected (0.00 sec) mysql> set global validate_password_policy=0; Query OK, 0 rows affected (0.00 sec) mysql> set password=password('mysql'); Query OK, 0 rows affected, 1 warning (0.00 sec) mysql> exit Bye [root@elegant-snap-3 /etc/yum.repos.d]$ mysql -uroot -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 3 Server version: 5.7.25 MySQL Community Server (GPL) Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sys | +--------------------+ 4 rows in set (0.01 sec) mysql>
then ojbk,have fun!
作者:九命猫幺
博客出处:http://www.cnblogs.com/yongestcat/
欢迎转载,转载请标明出处。
如果你觉得本文还不错,对你的学习带来了些许帮助,请帮忙点击右下角的推荐
博客出处:http://www.cnblogs.com/yongestcat/
欢迎转载,转载请标明出处。
如果你觉得本文还不错,对你的学习带来了些许帮助,请帮忙点击右下角的推荐