# 下载yum源的rpm包
wget https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
# 安装rpm包
rpm -Uvh mysql57-community-release-el7-11.noarch.rpm

# 检查是否有mysql源
[root@VM_61_120_centos local]# yum repolist enabled | grep mysql
mysql-connectors-community/x86_64    MySQL Connectors Community               51
mysql-tools-community/x86_64         MySQL Tools Community                    63
mysql57-community/x86_64             MySQL 5.7 Community Server              267
2、yum安装MySQL5.7

[root@VM_61_120_centos local]# yum install mysql-community-server
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package mysql-community-server.x86_64 0:5.7.22-1.el7 will be installed
--> Processing Dependency: mysql-community-common(x86-64) = 5.7.22-1.el7 for package: mysql-community-server-5.7.22-1.el7.x86_64
--> Processing Dependency: mysql-community-client(x86-64) >= 5.7.9 for package: mysql-community-server-5.7.22-1.el7.x86_64
--> Running transaction check
---> Package mysql-community-client.x86_64 0:5.7.22-1.el7 will be installed
--> Processing Dependency: mysql-community-libs(x86-64) >= 5.7.9 for package: mysql-community-client-5.7.22-1.el7.x86_64
---> Package mysql-community-common.x86_64 0:5.7.22-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.22-1.el7 will be obsoleting
--> Running transaction check
---> Package mysql-community-libs-compat.x86_64 0:5.7.22-1.el7 will be obsoleting
--> Finished Dependency Resolution

Dependencies Resolved

==============================================================================================================
Package Arch Version Repository Size
==============================================================================================================
Installing:
mysql-community-libs x86_64 5.7.22-1.el7 mysql57-community 2.1 M
replacing mariadb-libs.x86_64 1:5.5.56-2.el7
mysql-community-libs-compat x86_64 5.7.22-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.22-1.el7 mysql57-community 165 M
Installing for dependencies:
mysql-community-client x86_64 5.7.22-1.el7 mysql57-community 24 M
mysql-community-common x86_64 5.7.22-1.el7 mysql57-community 274 k

Transaction Summary
==============================================================================================================
Install 3 Packages (+2 Dependent packages)

Total download size: 193 M
Is this ok [y/d/N]: y
Downloading packages:
warning: /var/cache/yum/x86_64/7/mysql57-community/packages/mysql-community-common-5.7.22-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Public key for mysql-community-common-5.7.22-1.el7.x86_64.rpm is not installed
(1/5): mysql-community-common-5.7.22-1.el7.x86_64.rpm | 274 kB 00:00:02
(2/5): mysql-community-client-5.7.22-1.el7.x86_64.rpm | 24 MB 00:00:10
(3/5): mysql-community-libs-5.7.22-1.el7.x86_64.rpm | 2.1 MB 00:00:45
(4/5): mysql-community-libs-compat-5.7.22-1.el7.x86_64.rpm | 2.0 MB 00:00:40
(5/5): mysql-community-server-5.7.22-1.el7.x86_64.rpm | 165 MB 00:09:53
--------------------------------------------------------------------------------------------------------------
Total 308 kB/s | 193 MB 00:10:42
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-11.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.
Installing : mysql-community-common-5.7.22-1.el7.x86_64 1/6
Installing : mysql-community-libs-5.7.22-1.el7.x86_64 2/6
Installing : mysql-community-client-5.7.22-1.el7.x86_64 3/6
Installing : mysql-community-server-5.7.22-1.el7.x86_64 4/6
Installing : mysql-community-libs-compat-5.7.22-1.el7.x86_64 5/6
Erasing : 1:mariadb-libs-5.5.56-2.el7.x86_64 6/6
Verifying : mysql-community-libs-compat-5.7.22-1.el7.x86_64 1/6
Verifying : mysql-community-common-5.7.22-1.el7.x86_64 2/6
Verifying : mysql-community-server-5.7.22-1.el7.x86_64 3/6
Verifying : mysql-community-client-5.7.22-1.el7.x86_64 4/6
Verifying : mysql-community-libs-5.7.22-1.el7.x86_64 5/6
Verifying : 1:mariadb-libs-5.5.56-2.el7.x86_64 6/6

Installed:
mysql-community-libs.x86_64 0:5.7.22-1.el7 mysql-community-libs-compat.x86_64 0:5.7.22-1.el7
mysql-community-server.x86_64 0:5.7.22-1.el7

Dependency Installed:
mysql-community-client.x86_64 0:5.7.22-1.el7 mysql-community-common.x86_64 0:5.7.22-1.el7

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

Complete!
3、启动MySQL

查看MySQL默认生成的配置文件

vim /etc/my.cnf

# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html

[mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock

# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
启动并查看状态:

[root@VM_61_120_centos local]# service mysqld start
Redirecting to /bin/systemctl start mysqld.service
[root@VM_61_120_centos local]# service mysqld status
Redirecting to /bin/systemctl status mysqld.service
● mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: active (running) since Fri 2018-05-25 14:55:40 CST; 24s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 32347 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=0/SUCCESS)
Process: 32260 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
Main PID: 32351 (mysqld)
CGroup: /system.slice/mysqld.service
└─32351 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid

May 25 14:55:26 VM_61_120_centos systemd[1]: Starting MySQL Server...
May 25 14:55:40 VM_61_120_centos systemd[1]: Started MySQL Server.
4、设置mysqld服务开机自启动

systemctl enable mysqld
5、使用初始密码登录,并修改密码

从MySQL5.7开始不允许首次安装后使用空密码进行登录,系统会随机生成一个密码以供管理员首次登录使用,使用下面的命令查看此密码:

[root@VM_61_120_centos local]# cat /var/log/mysqld.log | grep 'A temporary password'
2018-05-25T06:55:29.033154Z 1 [Note] A temporary password is generated for root@localhost: zQpf,eGqh6l=
修改密码时,必须是强密码,要求包含大小写字母、数字及特殊字符,长度在6位以上;

[root@VM_61_120_centos local]# mysql -uroot -p'zQpf,eGqh6l='
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 5.7.22

Copyright (c) 2000, 2018, 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;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql> ALTER user 'root'@'localhost' identified by 'Bugaosuni01';
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
mysql> ALTER user 'root'@'localhost' identified by 'Bugaosuni_01';
Query OK, 0 rows affected (0.00 sec)

mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.00 sec)
6、本地使用新密码登录

[root@VM_61_120_centos ~]# mysql -uroot -p'Bugaosuni_01'
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 5.7.22 MySQL Community Server (GPL)

Copyright (c) 2000, 2018, 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)
登录成功,安装完成

7、远程连接

有可能报如下错误

Host '192.168.1.100' is not allowed to connect to this MySQL server
在本地登录数据库后,使用如下代码开放权限:

# 赋予全部权限在所有数据库和所有表上给root用户在任何主机上使用Bugaosuni_01这个密码登录
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'Bugaosuni_01' WITH GRANT OPTION;
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

mysql yum安装的更多相关文章

  1. Linux下yum安装MySQL yum安装MySQL指定版本

    yum安装MySQL 1. 查看有没有安装过     yum list installed MySQL* (有存在要卸载yum remove MySQL*)     rpm -qa | grep my ...

  2. yum 安装mysql, yum安装指定版本的mysql

    yum安装mysql: 1. 查看有没有安装过     yum list installed MySQL* (有存在要卸载yum remove MySQL*)     rpm -qa | grep m ...

  3. MySQL 8.0 yum安装和配置

    MySQL 8.0 centos7.5 x86_64 一.yum安装 1.先卸载机器和mysql有关的东西,有的安装了mariab-lib,会对安装有干扰,卸载了它. [root@localhost ...

  4. yum安装cacti

    环境: centos 6.5 -x64 cacti-0.8.7e.tar.gz mysql yum安装即可 yum服务使用centos自带的就行.如果是红帽请自行解决yum.本文不赘述. **注意:同 ...

  5. CDH集群安装配置(四)- mysql 的安装

    安装mysql,并且创建相关的表(只需要在chd1上面安装而且需要root权限)1.1 查看Centos自带mysql是否已经安装 yum list installed | grep mysql 卸载 ...

  6. mysql系列安装

    Mysql的5种安装方法:1.yum/rpm安装(适合要求不高,并发不大,公司内部,企业内部一些应用场景)2.编译安装(在线高并发业务)3.二进制安装(编译安装后,使用自带工具打包,然后拷贝到相同平台 ...

  7. Linux下yum安装MySQL

    写这篇文章的原因是:在刚开始使用Linux操作系统时想要搭建LAMP环境,于是开始在Google和百度上各种寻找资料,碰到了不是很多的问题后,我决定写这篇文章总结一下在Linux下yum安装MySQL ...

  8. centos7下使用yum安装mysql

    CentOS7的yum源中默认好像是没有mysql的.为了解决这个问题,我们要先下载mysql的repo源. 1. 下载mysql的repo源 wget http://repo.mysql.com/m ...

  9. centos 6.5 yum安装 mysql 5.6

    1. 查看系统里面有没有mysql 的repo   yum repolist all | grep mysql 2. 如果没有发现,则需要配置repo 注意,如果要使用5.7 或者其他任何版本,只能有 ...

随机推荐

  1. Vue项目启动后首页URL带的#该怎么去掉?

    修改router的mode为history就可以 const router = new VueRouter({mode: 'history', routes: [...]}) 实际修改后需要注意修改a ...

  2. hdu3530 双单调队列的维护

    单调队列有部分堆的功能,但其只能维护给定区间中比v大的值或者比v小的值,且其一般存储元素的下标. 思路:两个单调队列维护最大值与最小值的下标,如果区间的最大值最小值之差大于给定范围,则选择队首靠左的删 ...

  3. python 全栈开发,Day102(支付宝支付)

    昨日内容回顾 1. django请求生命周期? - 当用户在浏览器中输入url时,浏览器会生成请求头和请求体发给服务端 请求头和请求体中会包含浏览器的动作(action),这个动作通常为get或者po ...

  4. WPF插件开发:使用FrameworkElementAdapters时VS报错的问题

    使用MAF开发插件时FrameworkElementAdapters是个坑,查帮助手册发现这个类位于System.AddIn.Pipeline命名空间中,但是添加System.AddIn的引用后发现V ...

  5. DevExpress学习笔记之如何获取Repository Item的值

    上一章我们看到了如何在TreeList的单元格中动态绑定不同的控件,此类控件被称为In_Place Control.所谓“In_Place”,我的理解为“内置”控件,既然有“内”就相对的会有“外”,其 ...

  6. kafka相关知识点总结

    1.kafka是什么 类JMS消息队列,结合JMS中的两种模式(点对点模型,发布者/订阅者模型),可以有多个消费者主动拉取数据,在JMS中只有点对点模式才有消费者主动拉取数据. kafka是一个生产- ...

  7. BZOJ1068 [SCOI2007]压缩 区间动态规划 字符串

    欢迎访问~原文出处——博客园-zhouzhendong 去博客园看该题解 题目传送门 - BZOJ1068 题目概括 (其实是复制的) 给一个由小写字母组成的字符串,我们可以用一种简单的方法来压缩其中 ...

  8. Nightmare HDU1072

    非常标准的BFS 第一次写错了很多 1.到达4时设置为墙就好了  避免了死循环 2.不用开d数组   在结构体里面就行了 3.结构体初始化函数的写法: Node(int x=0,int y=0,int ...

  9. 【Java】 剑指offer(9) 斐波那契数列及青蛙跳台阶问题

     本文参考自<剑指offer>一书,代码采用Java语言. 更多:<剑指Offer>Java实现合集   题目 写一个函数,输入n,求斐波那契(Fibonacci)数列的第n项 ...

  10. hello C#

    一:程序 1.新建项目 2.修改名称位置 需要选择控制台应用程序. 3.项目新建后的效果 4.书写第一个程序 //下面是引用命名空间 using System; using System.Collec ...