在以下网址下载安装Red Hat Enterprise Linux 7 / Oracle Linux 7 (Architecture Independent), RPM Package(mysql57-community-release-el7-8.noarch.rpm)
http://dev.mysql.com/downloads/repo/yum/
可以直接执行
yum install http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
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
使用yum安装mysql server
yum install mysql-community-server Dependencies Resolved ========================================================================================================================================================================================================= Package Arch Version Repository Size ========================================================================================================================================================================================================= Installing: mysql-community-libs x86_64 5.7.14-1.el7 mysql57-community 2.1 M replacing mariadb-libs.x86_64 1:5.5.47-1.el7_2 mysql-community-libs-compat x86_64 5.7.14-1.el7 mysql57-community 2.0 M replacing mariadb-libs.x86_64 1:5.5.47-1.el7_2 mysql-community-server x86_64 5.7.14-1.el7 mysql57-community 152 M Installing for dependencies: mysql-community-client x86_64 5.7.14-1.el7 mysql57-community 24 M mysql-community-common x86_64 5.7.14-1.el7 mysql57-community 271 k Transaction Summary ========================================================================================================================================================================================================= Install 3 Packages (+2 Dependent packages) Total download size: 180 M Is this ok [y/d/N]: y
mysql 5.6 以上版本安装时会有一个随机密码,在mysql日志里查询
cat /var/log/mysqld.log |grep "A temporary password" [Note] A temporary password is generated for root@localhost: Thm34de873
Thm34de873就是此次mysql 5.7安装的随机密码.
开启mysqlserver服务,尝试登陆成功。
systemctl start mysqld mysql -u root -p Enter password: Thm34de873 Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 7 Server version: 5.7.14 Copyright (c) 2000, 2016, 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>
mysql 5.7 执行操作前要求必须更改初始密码,新密码写在单引号‘‘里。
ERROR 1820 (HY000): You must SET PASSWORD before executing this statement
mysql> SELECT 1;ERROR 1820 (HY000): You must SET PASSWORD before executing this statement mysql> SET PASSWORD = PASSWORD(‘new_password‘); Query OK, 0 rows affected (0.01 sec) mysql> SELECT 1;+---+ | 1 | +---+ | 1 | +---+ 1 row in set (0.00 sec)
密码有强度要求,如要关闭,在/etc/my.cnf中添加validate-password=OFF
本文出自 “专注打孔100年” 博客,请务必保留此出处http://titandeng.blog.51cto.com/823817/1841459
原文地址:http://titandeng.blog.51cto.com/823817/1841459