CentOS7默认安装的是Mariadb而不是mysql,而Mariadb是mysql的一个分支,

安装mysql会覆盖Mariadb

一、下载MySQL官方的 Yum Repository

[root@localhost ~]# wget -i -c https://repo.mysql.com//mysql57-community-release-el7-10.noarch.rpm
--2018-07-26 10:21:52-- https://repo.mysql.com//mysql57-community-release-el7-10.noarch.rpm
正在解析主机 repo.mysql.com (repo.mysql.com)... 104.88.152.154
正在连接 repo.mysql.com (repo.mysql.com)|104.88.152.154|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:25548 (25K) [application/x-redhat-package-manager]
正在保存至: “mysql57-community-release-el7-10.noarch.rpm” 100%[========================================================================================>] 25,548 36.5KB/s 用时 0.7s 2018-07-26 10:21:58 (36.5 KB/s) - 已保存 “mysql57-community-release-el7-10.noarch.rpm” [25548/25548]) -c: 没有那个文件或目录
在 -c 中找不到 URL。
FINISHED --2018-07-26 10:21:58--
Total wall clock time: 6.3s
Downloaded: 1 files, 25K in 0.7s (36.5 KB/s)
[root@localhost ~]#

二、安装mysql57-community-release-el7-10.noarch.rpm包,安装完之后会获取mysql的yum repo源

[root@localhost ~]# yum -y install mysql57-community-release-el7-10.noarch.rpm
已加载插件:fastestmirror
正在检查 mysql57-community-release-el7-10.noarch.rpm: mysql57-community-release-el7-10.noarch
mysql57-community-release-el7-10.noarch.rpm 将被安装
正在解决依赖关系
--> 正在检查事务
---> 软件包 mysql57-community-release.noarch.0.el7-10 将被 安装
--> 解决依赖关系完成 依赖关系解决 ==================================================================================================================================
Package 架构 版本 源 大小
==================================================================================================================================
正在安装:
mysql57-community-release noarch el7-10 /mysql57-community-release-el7-10.noarch 30 k 事务概要
==================================================================================================================================
安装 1 软件包 总计:30 k
安装大小:30 k
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在安装 : mysql57-community-release-el7-10.noarch 1/1
验证中 : mysql57-community-release-el7-10.noarch 1/1 已安装:
mysql57-community-release.noarch 0:el7-10 完毕!
[root@localhost ~]#
查看mysql的yum repo源:mysql-community.repo 和 mysql-community-source.repo [root@localhost ~]# ls -l /etc/yum.repos.d/
总用量 40
-rw-r--r--. 1 root root 1664 4月 29 00:35 CentOS-Base.repo
-rw-r--r--. 1 root root 1309 4月 29 00:35 CentOS-CR.repo
-rw-r--r--. 1 root root 649 4月 29 00:35 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root 314 4月 29 00:35 CentOS-fasttrack.repo
-rw-r--r--. 1 root root 630 4月 29 00:35 CentOS-Media.repo
-rw-r--r--. 1 root root 1331 4月 29 00:35 CentOS-Sources.repo
-rw-r--r--. 1 root root 4768 4月 29 00:35 CentOS-Vault.repo
-rw-r--r--. 1 root root 1627 4月 5 2017 mysql-community.repo
-rw-r--r--. 1 root root 1663 4月 5 2017 mysql-community-source.repo
[root@localhost ~]#

三、使用yum安装MySQL服务,此步骤会安装mysql的依赖包,会浪费一些时间

[root@localhost ~]# yum -y install mysql-community-server
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.zju.edu.cn
* extras: mirrors.zju.edu.cn
* updates: mirrors.shu.edu.cn
mysql-connectors-community | 2.5 kB 00:00:00
mysql-tools-community | 2.5 kB 00:00:00
mysql57-community | 2.5 kB 00:00:00
(1/3): mysql-connectors-community/x86_64/primary_db | 20 kB 00:00:05
(2/3): mysql-tools-community/x86_64/primary_db | 41 kB 00:00:06
(3/3): mysql57-community/x86_64/primary_db | 144 kB 00:00:06
正在解决依赖关系
--> 正在检查事务
---> 软件包 mysql-community-server.x86_64.0.5.7.22-1.el7 将被 安装
--> 正在处理依赖关系 mysql-community-common(x86-64) = 5.7.22-1.el7,它被软件包 mysql-community-server-5.7.22-1.el7.x86_64 需要
--> 正在处理依赖关系 mysql-community-client(x86-64) >= 5.7.9,它被软件包 mysql-community-server-5.7.22-1.el7.x86_64 需要
.
.
.
---> 软件包 perl-HTTP-Tiny.noarch.0.0.033-3.el7 将被 安装
---> 软件包 perl-parent.noarch.1.0.225-244.el7 将被 安装
--> 解决依赖关系完成 依赖关系解决 ==================================================================================================================================
Package 架构 版本 源 大小
==================================================================================================================================
正在安装:
mysql-community-libs x86_64 5.7.22-1.el7 mysql57-community 2.1 M
替换 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
替换 mariadb-libs.x86_64 1:5.5.56-2.el7
mysql-community-server x86_64 5.7.22-1.el7 mysql57-community 165 M
为依赖而安装:
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
net-tools x86_64 2.0-0.22.20131004git.el7 base 305 k
.
.
.
perl-threads x86_64 1.87-4.el7 base 49 k
perl-threads-shared x86_64 1.43-6.el7 base 39 k 事务概要
==================================================================================================================================
安装 3 软件包 (+30 依赖软件包) 总下载量:205 M
Downloading packages:
警告:/var/cache/yum/x86_64/7/mysql57-community/packages/mysql-community-common-5.7.22-1.el7.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY
mysql-community-common-5.7.22-1.el7.x86_64.rpm 的公钥尚未安装
(1/33): mysql-community-common-5.7.22-1.el7.x86_64.rpm | 274 kB 00:00:07
(2/33): mysql-community-libs-5.7.22-1.el7.x86_64.rpm | 2.1 MB 00:01:00
.
.
.
(32/33): mysql-community-client-5.7.22-1.el7.x86_64.rpm | 24 MB 00:11:56
(33/33): mysql-community-server-5.7.22-1.el7.x86_64.rpm | 165 MB 01:05:31
----------------------------------------------------------------------------------------------------------------------------------
总计 52 kB/s | 205 MB 01:07:47
从 file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql 检索密钥
导入 GPG key 0x5072E1F5:
用户ID : "MySQL Release Engineering <mysql-build@oss.oracle.com>"
指纹 : a4a9 4068 76fc bd3c 4567 70c8 8c71 8d3b 5072 e1f5
软件包 : mysql57-community-release-el7-10.noarch (installed)
来自 : /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在安装 : mysql-community-common-5.7.22-1.el7.x86_64 1/34
正在安装 : mysql-community-libs-5.7.22-1.el7.x86_64 2/34
.
.
.
正在安装 : mysql-community-libs-compat-5.7.22-1.el7.x86_64 33/34
正在删除 : 1:mariadb-libs-5.5.56-2.el7.x86_64 34/34
验证中 : mysql-community-libs-compat-5.7.22-1.el7.x86_64 1/34
验证中 : perl-HTTP-Tiny-0.033-3.el7.noarch 2/34
.
.
.
验证中 : perl-Text-ParseWords-3.29-4.el7.noarch 32/34
验证中 : mysql-community-client-5.7.22-1.el7.x86_64 33/34
验证中 : 1:mariadb-libs-5.5.56-2.el7.x86_64 34/34 已安装:
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 作为依赖被安装:
mysql-community-client.x86_64 0:5.7.22-1.el7 mysql-community-common.x86_64 0:5.7.22-1.el7
net-tools.x86_64 0:2.0-0.22.20131004git.el7 perl.x86_64 4:5.16.3-292.el7
.
.
.
perl-threads.x86_64 0:1.87-4.el7 perl-threads-shared.x86_64 0:1.43-6.el7 替代:
mariadb-libs.x86_64 1:5.5.56-2.el7 完毕!
[root@localhost ~]#

四、启动并查看Mysql状态

[root@localhost ~]# systemctl start mysqld.service
[root@localhost ~]# systemctl status mysqld.service
● mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: active (running) since 四 2018-07-26 12:21:21 CST; 11s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 4113 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=0/SUCCESS)
Process: 4040 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
Main PID: 4116 (mysqld)
CGroup: /system.slice/mysqld.service
└─4116 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid 7月 26 12:21:06 localhost.localdomain systemd[1]: Starting MySQL Server...
7月 26 12:21:21 localhost.localdomain systemd[1]: Started MySQL Server.
[root@localhost ~]#

五、查看mysql初始化密码

  • 此次mysql初始化密码为:1#(EdfAGebE5
  • 需要使用grep "password" /var/log/mysqld.log命令查看
[root@localhost ~]# grep "password" /var/log/mysqld.log
2018-07-26T04:21:09.246395Z 1 [Note] A temporary password is generated for root@localhost: 1#(EdfAGebE5
[root@localhost ~]#

六、登陆mysql,并输入出厂密码

[root@localhost ~]# 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.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>
 

七、修改root用户密码

  • mysql强制用户必须修改密码,不然只能登陆,却不能操作数据库(注意:在修改密码时密码复杂度不能太简单,如:123456,但是我们自己开发时又不想设置的太复杂,所以在修改密码之前先修改密码复杂度,如若不想修改密码复杂度,请直接执行ALTER语句)
# 密码可以只有一种字符
mysql> set global validate_password_policy=0;
Query OK, 0 rows affected (0.00 sec)
# 密码最小长度为1
mysql> set global validate_password_length=1;
Query OK, 0 rows affected (0.00 sec) mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'hadoop';
Query OK, 0 rows affected (0.00 sec) mysql>

八、修改默认字符集

  • mysql默认的database和server字符集为latin1,我们需要把它修改为utf8
mysql> show variables like 'character%';
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | latin1 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | latin1 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.01 sec) mysql> set character_set_database=utf8;
Query OK, 0 rows affected, 1 warning (0.00 sec) mysql> set character_set_server=utf8;
Query OK, 0 rows affected (0.00 sec) mysql>

九、授权root用户可以从任意主机登录(注意将hadoop换成自己的密码)

mysql> grant all privileges on *.* to root@"%" identified by "hadoop" with grant option;
Query OK, 0 rows affected, 1 warning (0.00 sec) mysql>

十、退出并重启mysql服务

mysql> quit
Bye
[root@localhost ~]# systemctl restart mysqld.service
[root@localhost ~]#

十一、开放端口3306端口

[root@localhost ~]# firewall-cmd --zone=public --add-port=3306/tcp --permanent
success
[root@localhost ~]# firewall-cmd --reload
success
[root@localhost ~]#

CentOS7-Minimal安装MySQL服务的更多相关文章

  1. centos7 minimal 安装mysql

    CentOS 7.3.1611 安装 MySQL 2017年06月08日 23:02:08 阅读数:250   依赖 MySQL 依赖 libaio,所以先要安装 libaio yum search ...

  2. Centos7下安装mysql服务

    yum install -y perl-Module-Install.noarch yum -y install perl perl-devel #命令下载mysql wget http://dev. ...

  3. CentOS7下安装MySQL并配置远程连接

    一.CentOS7下安装MySQL数据库 CentOS7默认的安装包里面已经没有 MySQL-Server安装包了,远程镜像中也没有了. 默认的是MariaDB (MySQL的一个分支,开发这个分支的 ...

  4. CentOS7.4安装MySQL踩坑记录

    CentOS7.4安装MySQL踩坑记录 time: 2018.3.19 CentOS7.4安装MySQL时网上的文档虽然多但是不靠谱的也多, 可能因为版本与时间的问题, 所以记录下自己踩坑的过程, ...

  5. centos7 Minimal安装没有ifconfig

    centos7 Minimal  安装后 ip addr 系统的网卡没有分配IP地址 网卡为ens33 cd /etc/sysconfig/network-scripts vi ifcfg-ens33 ...

  6. Linux环境下安装mysql服务

    我使用的是阿里云的ECS服务,系统是CentOS7,安装mysql版本是5.7 第一步,通过 wget -i -c http://dev.mysql.com/get/mysql57-community ...

  7. CentOS7.5 安装MySql教程

    CentOS7位安装MySql教程 1.先检查系统是否装有mysql rpm -qa | grep mysql 2.下载mysql的repo源 wget http://repo.mysql.com/m ...

  8. 如何安装mysql服务

    我刚开始安装mysql的时候,在windows的服务里面可以看到,但是装了以后有一段时间没有用它了,我在准备从windows的服务里面启动mysql服务的时候,发现没有mysql的服务了,那我的解决办 ...

  9. CentOS7下安装Mysql和Memcached 以及 使用C#操作Mysql和Memcached

    我本身是学.net的,但是现在很多主流SQL和NOSQL都是部置在linux下,本着好学的精神,前段时间装了个虚拟机,在其装上CentOS64位的服务器系统,对于英文0基础,linux0基础的我来说, ...

随机推荐

  1. delphi xe10 蓝牙

    //蓝牙 System.Bluetooth //单元中主要包含以下几个类 TBluetoothManager.TBluetoothDeviceList.TBluetoothAdapter.TBluet ...

  2. 线性基算贡献——19牛客多校第一场H

    /* 给定数组a[],求有多少集合的异或值为0,将这些集合的大小之和求出来 对于每个数来说,如果除去这个数后数组里做出的线性基和这个数线性相关,那么这个数贡献就是2^(n-1-线性基的大小) 反之这个 ...

  3. 28 利用平面对应关系求解RT空间转换矩阵

    0 引言 问题背景:给定CAD模型与点云的情况下,基于CAD比对实现对实测点云的尺寸测量是三维测量技术中一种常用的思路.该思路的关键问题在于需要精确求解CAD模型与点云之间的空间转换矩阵.采用ICP( ...

  4. NX二次开发-UFUN重命名图纸页UF_DRAW_rename_drawing

    #include <uf.h> #include <uf_draw.h> #include <uf_drf.h> #include <uf_obj.h> ...

  5. NX二次开发-遍历当前part所有component,把装配子部件设置成工作部件

    NX11+VS2013 #include <uf.h> #include <uf_disp.h> #include <uf_modl.h> #include < ...

  6. Python字典列表字段重组形成新的字典

    最近遇到这样一个需求,需要将字典列表中的字段进行重组,形成一个新的字典.举个例子吧: l1 = [{"x": 22, "y": 22, "demand ...

  7. 黑科技之杜教bm

    这个板子能够解决任何线性递推式,只要你确定某个数列的某项只与前几项线性相关,那么把它前若干项丢进去,这个板子就能给你返回你要求的某项的值. 原理???(待补充) #include<bits/st ...

  8. JDK简介和mac下安装和查看版本命令

    1.什么是JDK? JDK:Java Development Kit,是 Java 语言的软件开发工具包(SDK).没有JDK的话,无法编译Java程序(指java源码.java文件). SE(Jav ...

  9. project2_login(登录窗口)

    该project是在网易云课堂上的公开课<用 python 和 tkinter 做简单的窗口视窗>课程当中学习的,是该课程中的一个结课小项目,项目中的知识点内容涉及该课程中所学习到的大多数 ...

  10. iOS 7.1的Safari为meta标签新增minimal-ui属性,在网页加载时隐藏地址栏与导航栏

    在 iOS 7.1 的 Safari 中为 meta 标签新增 minimal-ui 属性,让网页在加载时便可隐藏顶部的地址栏与底部的导航栏. 如何实现?你只需将“minimal-ui”加入 view ...