CentOS7-Minimal安装MySQL服务
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服务的更多相关文章
- centos7 minimal 安装mysql
CentOS 7.3.1611 安装 MySQL 2017年06月08日 23:02:08 阅读数:250 依赖 MySQL 依赖 libaio,所以先要安装 libaio yum search ...
- Centos7下安装mysql服务
yum install -y perl-Module-Install.noarch yum -y install perl perl-devel #命令下载mysql wget http://dev. ...
- CentOS7下安装MySQL并配置远程连接
一.CentOS7下安装MySQL数据库 CentOS7默认的安装包里面已经没有 MySQL-Server安装包了,远程镜像中也没有了. 默认的是MariaDB (MySQL的一个分支,开发这个分支的 ...
- CentOS7.4安装MySQL踩坑记录
CentOS7.4安装MySQL踩坑记录 time: 2018.3.19 CentOS7.4安装MySQL时网上的文档虽然多但是不靠谱的也多, 可能因为版本与时间的问题, 所以记录下自己踩坑的过程, ...
- centos7 Minimal安装没有ifconfig
centos7 Minimal 安装后 ip addr 系统的网卡没有分配IP地址 网卡为ens33 cd /etc/sysconfig/network-scripts vi ifcfg-ens33 ...
- Linux环境下安装mysql服务
我使用的是阿里云的ECS服务,系统是CentOS7,安装mysql版本是5.7 第一步,通过 wget -i -c http://dev.mysql.com/get/mysql57-community ...
- CentOS7.5 安装MySql教程
CentOS7位安装MySql教程 1.先检查系统是否装有mysql rpm -qa | grep mysql 2.下载mysql的repo源 wget http://repo.mysql.com/m ...
- 如何安装mysql服务
我刚开始安装mysql的时候,在windows的服务里面可以看到,但是装了以后有一段时间没有用它了,我在准备从windows的服务里面启动mysql服务的时候,发现没有mysql的服务了,那我的解决办 ...
- CentOS7下安装Mysql和Memcached 以及 使用C#操作Mysql和Memcached
我本身是学.net的,但是现在很多主流SQL和NOSQL都是部置在linux下,本着好学的精神,前段时间装了个虚拟机,在其装上CentOS64位的服务器系统,对于英文0基础,linux0基础的我来说, ...
随机推荐
- Java分页查询工具类
public class PageList<T> { private int totalpage; //总页数 private int totalcount; //总记录数 private ...
- JZOJ5153:树形图求和
Description Input Output HINT 题解: 一种很直观的想法是通过矩阵生成树求树形图方法数ans以及不包含某一条边i的树形图方法数ans[i],则答案为Σ(ans-ans[i] ...
- sqlserver 获取实例上用户数据库的数据字典
原理很简单:将获取数据字典信息(通过动态视图获取)存入到目标表(数据字典表)中即可. 本人自用实例 1)创建相关的字典表 use YWMonitor GO SET ANSI_NULLS ON GO S ...
- 数据结构C++版-线性表
PS:资料来源慕课网视频. 一.什么是线性表 线性表是n个数据元素的有限序列. 分类: 二.补充知识点 1.栈和队列有出操作.入操作,对应线性表(数组)为插入元素和删除元素,而线性表中要获取指定元素值 ...
- LeetCode 704. Binary Search (二分查找)
题目标签:Binary Search 很标准的一个二分查找,具体看code. Java Solution: Runtime: 0 ms, faster than 100 % Memory Usage ...
- iOS开发之3D Touch
1.简介 3DTouch是在6s之后苹果的一项技术,只能在6s及其以上机型真机运行,Xcode的模拟器是不支持的. Quick Actions(点击icon的快捷方式) Peek&Pop(应用 ...
- 3、发送第一个api请求
接口地址:https://www.v2ex.com/api/topics/latest.json Method: GET Authentication: None 我们打开postman,方法选择ge ...
- 2019-8-31-C#-通过编程的方法在桌面创建回收站快捷方式
title author date CreateTime categories C# 通过编程的方法在桌面创建回收站快捷方式 lindexi 2019-08-31 16:55:58 +0800 201 ...
- Linux-iptables-route-rule
详情: http://www.mamicode.com/info-detail-1412618.html 最后面有粘贴 linux系统路由表 linux一共0-255个路由表 linux可以自定义从 ...
- canvas像素的操作
###在canvas中的像素操作 到目前为止,我们尚未深入了解Canvas画布真实像素的原理,事实上, 你可以直接通过ImageData对象操纵像素数据,直接读取或将数据数组写入该对象中 ###得到场 ...