centos7 安装mysql5.7

[root@izbp1buyhgwtrvlxv3u2gqz soft]# wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
--2019-04-18 17:24:29-- http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
Resolving dev.mysql.com (dev.mysql.com)... 137.254.60.11
Connecting to dev.mysql.com (dev.mysql.com)|137.254.60.11|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: https://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm [following]
--2019-04-18 17:24:30-- https://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
Connecting to dev.mysql.com (dev.mysql.com)|137.254.60.11|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://repo.mysql.com//mysql57-community-release-el7-8.noarch.rpm [following]
--2019-04-18 17:24:31-- https://repo.mysql.com//mysql57-community-release-el7-8.noarch.rpm
Resolving repo.mysql.com (repo.mysql.com)... 104.127.195.16
Connecting to repo.mysql.com (repo.mysql.com)|104.127.195.16|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 9116 (8.9K) [application/x-redhat-package-manager]
Saving to: ‘mysql57-community-release-el7-8.noarch.rpm’

100%[=================================================================================================================================================>] 9,116 --.-K/s in 0s

2019-04-18 17:24:31 (218 MB/s) - ‘mysql57-community-release-el7-8.noarch.rpm’ saved [9116/9116]

[root@izbp1buyhgwtrvlxv3u2gqz soft]# yum localinstall mysql57-community-release-el7-8.noarch.rpm
Loaded plugins: fastestmirror
Examining mysql57-community-release-el7-8.noarch.rpm: mysql57-community-release-el7-8.noarch
Marking mysql57-community-release-el7-8.noarch.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package mysql57-community-release.noarch 0:el7-8 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===========================================================================================================================================================================================
Package Arch Version Repository Size
===========================================================================================================================================================================================
Installing:
mysql57-community-release noarch el7-8 /mysql57-community-release-el7-8.noarch 8.2 k

Transaction Summary
===========================================================================================================================================================================================
Install 1 Package

Total size: 8.2 k
Installed size: 8.2 k
Is this ok [y/d/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : mysql57-community-release-el7-8.noarch 1/1
Verifying : mysql57-community-release-el7-8.noarch 1/1

Installed:
mysql57-community-release.noarch 0:el7-8

Complete!
[root@izbp1buyhgwtrvlxv3u2gqz soft]# yum repolist enabled | grep “mysql.-community.”
[root@izbp1buyhgwtrvlxv3u2gqz soft]# yum install mysql-community-server
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
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.56-2.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
--> 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.56-2.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.56-2.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:
postfix x86_64 2:2.10.1-7.el7 base 2.4 M

Transaction Summary
===========================================================================================================================================================================================
Install 3 Packages (+3 Dependent packages)
Upgrade ( 1 Dependent package)

Total download size: 196 M
Is this ok [y/d/N]: y
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
(1/7): 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/7): mysql-community-common-5.7.25-1.el7.x86_64.rpm | 274 kB 00:00:00
(3/7): mysql-community-libs-5.7.25-1.el7.x86_64.rpm | 2.2 MB 00:00:00
(4/7): mysql-community-libs-compat-5.7.25-1.el7.x86_64.rpm | 2.0 MB 00:00:00
(5/7): postfix-2.10.1-7.el7.x86_64.rpm | 2.4 MB 00:00:00
(6/7): mysql-community-client-5.7.25-1.el7.x86_64.rpm | 24 MB 00:00:02
(7/7): mysql-community-server-5.7.25-1.el7.x86_64.rpm | 165 MB 00:00:15
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 12 MB/s | 196 MB 00:00:16
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Importing GPG key 0x5072E1F5:
Userid : "MySQL Release Engineering <mysql-build@oss.oracle.com>"
Fingerprint: a4a9 4068 76fc bd3c 4567 70c8 8c71 8d3b 5072 e1f5
Package : mysql57-community-release-el7-8.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
Installing : mysql-community-common-5.7.25-1.el7.x86_64 1/9
Installing : mysql-community-libs-5.7.25-1.el7.x86_64 2/9
Installing : mysql-community-libs-compat-5.7.25-1.el7.x86_64 3/9
Installing : mysql-community-client-5.7.25-1.el7.x86_64 4/9
Installing : libaio-0.3.109-13.el7.x86_64 5/9
Installing : mysql-community-server-5.7.25-1.el7.x86_64 6/9
Updating : 2:postfix-2.10.1-7.el7.x86_64 7/9
Cleanup : 2:postfix-2.10.1-6.el7.x86_64 8/9
Erasing : 1:mariadb-libs-5.5.56-2.el7.x86_64 9/9
Verifying : mysql-community-libs-5.7.25-1.el7.x86_64 1/9
Verifying : mysql-community-libs-compat-5.7.25-1.el7.x86_64 2/9
Verifying : mysql-community-common-5.7.25-1.el7.x86_64 3/9
Verifying : 2:postfix-2.10.1-7.el7.x86_64 4/9
Verifying : mysql-community-server-5.7.25-1.el7.x86_64 5/9
Verifying : mysql-community-client-5.7.25-1.el7.x86_64 6/9
Verifying : libaio-0.3.109-13.el7.x86_64 7/9
Verifying : 1:mariadb-libs-5.5.56-2.el7.x86_64 8/9
Verifying : 2:postfix-2.10.1-6.el7.x86_64 9/9

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:
postfix.x86_64 2:2.10.1-7.el7

Replaced:
mariadb-libs.x86_64 1:5.5.56-2.el7

Complete!
[root@izbp1buyhgwtrvlxv3u2gqz soft]# systemctl start mysqld
[root@izbp1buyhgwtrvlxv3u2gqz soft]# systemctl status mysqld
● mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: active (running) since Thu 2019-04-18 17:27:28 CST; 13s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 13346 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=0/SUCCESS)
Process: 13273 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
Main PID: 13351 (mysqld)
CGroup: /system.slice/mysqld.service
└─13351 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid

Apr 18 17:27:22 izbp1buyhgwtrvlxv3u2gqz systemd[1]: Starting MySQL Server...
Apr 18 17:27:28 izbp1buyhgwtrvlxv3u2gqz systemd[1]: Started MySQL Server.
[root@izbp1buyhgwtrvlxv3u2gqz soft]# systemctl enable mysqld
[root@izbp1buyhgwtrvlxv3u2gqz soft]# systemctl daemon-reload

[root@izbp1buyhgwtrvlxv3u2gqz soft]# systemctl daemon-reload
[root@izbp1buyhgwtrvlxv3u2gqz soft]# grep 'temporary password' /var/log/mysqld.log
2019-04-18T09:27:24.224008Z 1 [Note] A temporary password is generated for root@localhost: eGq3wa,L*!_s
[root@izbp1buyhgwtrvlxv3u2gqz soft]# #
[root@izbp1buyhgwtrvlxv3u2gqz soft]# cd /etc/
[root@izbp1buyhgwtrvlxv3u2gqz etc]# ls
adjtime cron.deny ethertypes hosts login.defs nsswitch.conf.bak protocols securetty sysctl.d
aliases cron.hourly exports hosts.allow logrotate.conf ntp python security systemd
aliases.db cron.monthly favicon.png hosts.deny logrotate.d ntp.conf rc0.d selinux system-release
alternatives crontab filesystems init.d lsb-release.d openldap rc1.d services system-release-cpe
anacrontab cron.weekly firewalld inittab machine-id opt rc2.d sestatus.conf terminfo
asound.conf crypttab fstab inputrc machine-info os-release rc3.d shadow timezone
at.deny csh.cshrc gcrypt iproute2 magic pam.d rc4.d shadow- tmpfiles.d
audisp csh.login GeoIP.conf issue mail.rc passwd rc5.d shells tuned
audit dbus-1 GeoIP.conf.default issue.net makedumpfile.conf.sample passwd- rc6.d skel udev
backup default gnupg kdump.conf man_db.conf pkcs11 rc.d ssh vconsole.conf
bash_completion.d depmod.d GREP_COLORS kernel mke2fs.conf pki rc.local ssl vimrc
bashrc dhcp groff krb5.conf modprobe.d plymouth redhat-lsb statetab virc
binfmt.d DIR_COLORS group krb5.conf.d modules-load.d pm redhat-release statetab.d wgetrc
centos-release DIR_COLORS.256color group- ld.so.cache motd polkit-1 resolv.conf subgid wpa_supplicant
centos-release-upstream DIR_COLORS.lightbgcolor grub2.cfg ld.so.conf mtab popt.d rpc subuid X11
chkconfig.d dracut.conf grub.d ld.so.conf.d my.cnf postfix rpm sudo.conf xdg
chrony.conf dracut.conf.d gshadow libaudit.conf my.cnf.d ppp rsyslog.conf sudoers xinetd.d
chrony.keys dracut.conf.d? gshadow- libnl NetworkManager prelink.conf.d rsyslog.d sudoers.d yum
cloud e2fsck.conf gss libuser.conf networks printcap rwtab sudo-ldap.conf yum.conf
cron.d eni_utils host.conf locale.conf nscd.conf profile rwtab.d sysconfig yum.repos.d
cron.daily environment hostname localtime nsswitch.conf profile.d sasl2 sysctl.conf
[root@izbp1buyhgwtrvlxv3u2gqz etc]# vi my.cnf
[root@izbp1buyhgwtrvlxv3u2gqz etc]# systemctl restart mysqld
[root@izbp1buyhgwtrvlxv3u2gqz etc]# mysql -uroot -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
[root@izbp1buyhgwtrvlxv3u2gqz etc]# 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

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 'root123!@#'
-> ;
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
mysql> alter user 'root'@'localhost' identified by 'root123!@#';
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
mysql> SHOW VARIABLES LIKE 'validate_password%'
-> ;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql> SHOW VARIABLES LIKE 'validate_password%';

原文地址:https://www.cnblogs.com/myibm/p/10731060.html