YUM方式安装MYSQL5.7
程序员文章站
2022-04-29 08:24:48
首先mysql官网下载yum源https://dev.mysql.com/downloads/repo/yum/然后将下载好的rpm文件安装并校验[root@elegant-snap-3 /stage]$ rpm -ivh mysql80-community-release-el7-2.noarch... ......
首先mysql官网下载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!