文档章节

Centos7安装mysql5.7社区版

V
 ValSong
发布于 2016/11/20 23:43
字数 2402
阅读 128
收藏 0

##- Centos7安装mysql5.7社区版

ps:本教程是在一定程度上参考了网络上的资源结合实际操作总结而成,如有不当指出请大神们批评指正,谢谢!(●'◡'●)

###1.从官网下载mysql-5.7.16-1.el7.x86_64.rpm-bundle.tar: http://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.16-1.el7.x86_64.rpm-bundle.tar

###2.解压

[root@localhost ~]# tar -xvf mysql-5.7.16-1.el7.x86_64.rpm-bundle.tar
mysql-community-libs-compat-5.7.16-1.el7.x86_64.rpm
mysql-community-devel-5.7.16-1.el7.x86_64.rpm
mysql-community-minimal-debuginfo-5.7.16-1.el7.x86_64.rpm
mysql-community-libs-5.7.16-1.el7.x86_64.rpm
mysql-community-common-5.7.16-1.el7.x86_64.rpm
mysql-community-embedded-compat-5.7.16-1.el7.x86_64.rpm
mysql-community-test-5.7.16-1.el7.x86_64.rpm
mysql-community-embedded-devel-5.7.16-1.el7.x86_64.rpm
mysql-community-server-minimal-5.7.16-1.el7.x86_64.rpm
mysql-community-server-5.7.16-1.el7.x86_64.rpm
mysql-community-client-5.7.16-1.el7.x86_64.rpm
mysql-community-embedded-5.7.16-1.el7.x86_64.rpm
 

###2.安装:

[root@localhost ~]# rpm -i mysql-community-common-5.7.16-1.el7.x86_64.rpm 
warning: mysql-community-common-5.7.16-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
	file /usr/share/mysql/czech/errmsg.sys from install of mysql-community-common-5.7.16-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
	file /usr/share/mysql/danish/errmsg.sys from install of mysql-community-common-5.7.16-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
	file /usr/share/mysql/dutch/errmsg.sys from install of mysql-community-common-5.7.16-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
	file /usr/share/mysql/english/errmsg.sys from install of mysql-community-common-5.7.16-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
	file /usr/share/mysql/estonian/errmsg.sys from install of mysql-community-common-5.7.16-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
	file /usr/share/mysql/french/errmsg.sys from install of mysql-community-common-5.7.16-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
	file /usr/share/mysql/german/errmsg.sys from install of mysql-community-common-5.7.16-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
	file /usr/share/mysql/greek/errmsg.sys from install of mysql-community-common-5.7.16-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
	file /usr/share/mysql/hungarian/errmsg.sys from install of mysql-community-common-5.7.16-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
	file /usr/share/mysql/italian/errmsg.sys from install of mysql-community-common-5.7.16-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
	file /usr/share/mysql/japanese/errmsg.sys from install of mysql-community-common-5.7.16-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
	file /usr/share/mysql/korean/errmsg.sys from install of mysql-community-common-5.7.16-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
	file /usr/share/mysql/norwegian-ny/errmsg.sys from install of mysql-community-common-5.7.16-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
	file /usr/share/mysql/norwegian/errmsg.sys from install of mysql-community-common-5.7.16-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
	file /usr/share/mysql/polish/errmsg.sys from install of mysql-community-common-5.7.16-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
	file /usr/share/mysql/portuguese/errmsg.sys from install of mysql-community-common-5.7.16-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
	file /usr/share/mysql/romanian/errmsg.sys from install of mysql-community-common-5.7.16-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
	file /usr/share/mysql/russian/errmsg.sys from install of mysql-community-common-5.7.16-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
	file /usr/share/mysql/serbian/errmsg.sys from install of mysql-community-common-5.7.16-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
	file /usr/share/mysql/slovak/errmsg.sys from install of mysql-community-common-5.7.16-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
	file /usr/share/mysql/spanish/errmsg.sys from install of mysql-community-common-5.7.16-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
	file /usr/share/mysql/swedish/errmsg.sys from install of mysql-community-common-5.7.16-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
	file /usr/share/mysql/ukrainian/errmsg.sys from install of mysql-community-common-5.7.16-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
	file /usr/share/mysql/charsets/Index.xml from install of mysql-community-common-5.7.16-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
	file /usr/share/mysql/charsets/armscii8.xml from install of mysql-community-common-5.7.16-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
	file /usr/share/mysql/charsets/ascii.xml from install of mysql-community-common-5.7.16-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
	file /usr/share/mysql/charsets/cp1250.xml from install of mysql-community-common-5.7.16-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
	file /usr/share/mysql/charsets/cp1256.xml from install of mysql-community-common-5.7.16-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
	file /usr/share/mysql/charsets/cp1257.xml from install of mysql-community-common-5.7.16-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
	file /usr/share/mysql/charsets/cp850.xml from install of mysql-community-common-5.7.16-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
	file /usr/share/mysql/charsets/cp852.xml from install of mysql-community-common-5.7.16-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
	file /usr/share/mysql/charsets/cp866.xml from install of mysql-community-common-5.7.16-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
	file /usr/share/mysql/charsets/dec8.xml from install of mysql-community-common-5.7.16-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
	file /usr/share/mysql/charsets/geostd8.xml from install of mysql-community-common-5.7.16-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
	file /usr/share/mysql/charsets/greek.xml from install of mysql-community-common-5.7.16-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
	file /usr/share/mysql/charsets/hebrew.xml from install of mysql-community-common-5.7.16-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
	file /usr/share/mysql/charsets/hp8.xml from install of mysql-community-common-5.7.16-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
	file /usr/share/mysql/charsets/keybcs2.xml from install of mysql-community-common-5.7.16-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
	file /usr/share/mysql/charsets/koi8r.xml from install of mysql-community-common-5.7.16-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
	file /usr/share/mysql/charsets/koi8u.xml from install of mysql-community-common-5.7.16-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
	file /usr/share/mysql/charsets/latin1.xml from install of mysql-community-common-5.7.16-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
	file /usr/share/mysql/charsets/latin2.xml from install of mysql-community-common-5.7.16-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
	file /usr/share/mysql/charsets/latin5.xml from install of mysql-community-common-5.7.16-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
	file /usr/share/mysql/charsets/latin7.xml from install of mysql-community-common-5.7.16-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
	file /usr/share/mysql/charsets/macce.xml from install of mysql-community-common-5.7.16-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
	file /usr/share/mysql/charsets/macroman.xml from install of mysql-community-common-5.7.16-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
	file /usr/share/mysql/charsets/swe7.xml from install of mysql-community-common-5.7.16-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64

说明安装过程中与mariadb-libs发生了了冲突

卸载mariadb-libs

[root@localhost ~]# yum -y remove mariadb-libs.x86_64
Existing lock /var/run/yum.pid: another copy is running as pid 4060.
Another app is currently holding the yum lock; waiting for it to exit...
  The other application is: PackageKit
    Memory : 118 M RSS (1.4 GB VSZ)
    Started: Sun Nov 20 09:57:20 2016 - 04:54 ago
    State  : Sleeping, pid: 4060

提示yum被锁住了pid是4060

kill -9 4060

再次卸载mariadb-libs

[root@localhost ~]# yum -y remove mariadb-libs.x86_64
BDB2053 Freeing read locks for locker 0x3da: 4060/140620739848000
BDB2053 Freeing read locks for locker 0x3dc: 4060/140620739848000
Loaded plugins: fastestmirror, langpacks
Resolving Dependencies
--> Running transaction check
---> Package mariadb-libs.x86_64 1:5.5.44-2.el7.centos will be erased
--> 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
--> Running transaction check
---> Package postfix.x86_64 2:2.10.1-6.el7 will be erased
--> Finished Dependency Resolution

Dependencies Resolved

===============================================================================================================================================================================================================
 Package                                           Arch                                        Version                                                    Repository                                      Size
===============================================================================================================================================================================================================
Removing:
 mariadb-libs                                      x86_64                                      1:5.5.44-2.el7.centos                                      @anaconda                                      4.4 M
Removing for dependencies:
 postfix                                           x86_64                                      2:2.10.1-6.el7                                             @anaconda                                       12 M

Transaction Summary
===============================================================================================================================================================================================================
Remove  1 Package (+1 Dependent package)

Installed size: 17 M
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Erasing    : 2:postfix-2.10.1-6.el7.x86_64                                                                                                                                                               1/2 
  Erasing    : 1:mariadb-libs-5.5.44-2.el7.centos.x86_64                                                                                                                                                   2/2 
  Verifying  : 1:mariadb-libs-5.5.44-2.el7.centos.x86_64                                                                                                                                                   1/2 
  Verifying  : 2:postfix-2.10.1-6.el7.x86_64                                                                                                                                                               2/2 

Removed:
  mariadb-libs.x86_64 1:5.5.44-2.el7.centos                                                                                                                                                                    

Dependency Removed:
  postfix.x86_64 2:2.10.1-6.el7                                                                                                                                                                                

Complete!

卸载mariadb-libs完成!

重新安装mysql-community-common-5.7.16-1.el7.x86_64.rpm

[root@localhost ~]# rpm -i mysql-community-common-5.7.16-1.el7.x86_64.rpm 
warning: mysql-community-common-5.7.16-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY

搞定!

接下来依次安装:

[root@localhost ~]# rpm -i mysql-community-libs-5.7.16-1.el7.x86_64.rpm
warning: mysql-community-libs-5.7.16-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
 
[root@localhost ~]# rpm -i mysql-community-client-5.7.16-1.el7.x86_64.rpm
warning: mysql-community-client-5.7.16-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY

[root@localhost ~]# rpm -i mysql-community-server-5.7.16-1.el7.x86_64.rpm
warning: mysql-community-server-5.7.16-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY

###3.启动mysql:

[root@localhost ~]# service mysqld start
Redirecting to /bin/systemctl start  mysqld.service

###4.查看密码: 由于该版本安装后,mysql会自动生成一个随机密码在/var/log/mysqld.log中

查看密码

[root@localhost ~]# cat /var/log/mysqld.log|grep -n password

会看到其中有一行类似下面:

6:2016-11-20T15:12:19.209149Z 1 [Note] A temporary password is generated for root@localhost: Jj!LR+pj>2ad

其中Jj!LR+pj>2ad就是密码了。


###5.登录:

[root@localhost ~]# mysql -u root -p
Enter password: 

###6.登录成功后用命令修改密码

mysql> alter user 'root'@'localhost' identified by '123456';
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
//密码强度不够校验没通过

###7.降低密码强度(可选)

mysql> set global validate_password_policy =0; //默认是1,即MEDIUM,所以刚开始设置的密码必须符合长度,且必须含有数字,小写或大写字母,特殊字符。
mysql> set global validate_password_length=4; //指定了密码中数据的长度

###8.修改密码

mysql> alter user root@localhost identified by '123456';
Query OK, 0 rows affected (0.00 sec)

成功


###9.创建数据库

mysql> create database rise;

rise是数据库名


###10.创建用户远程并赋予远程连接的权限

mysql> grant all privileges on rise.* to val@'%' identified by '123456';
mysql> flush privileges;

%表示任意IP(可以指定IP)、val是用户名、123456是密码


###11.使用nativecat远程连接数据

提示:2003 -Can't connect to MySQL server on '10.0.0.18'(10038)

说明端口不通


###12.开通3306端口 Centos升级到7之后,发现无法使用iptables控制Linuxs的端口,google之后发现Centos 7使用firewalld代替了原来的iptables。 下面记录如何使用firewalld开放Linux端口:

开启端口

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

命令含义: --zone #作用域 --add-port=3306/tcp #添加端口,格式为:端口/通讯协议 --permanent #永久生效,没有此参数重启后失效

重启防火墙

[root@localhost ~]# firewall-cmd --reload

###- OK,搞定

© 著作权归作者所有

共有 人打赏支持
V
粉丝 2
博文 17
码字总数 10814
作品 0
黄浦
程序员
私信 提问
MySQL 安装配置 CentOS7_安装MySQL5.7

MySQL5.7RPM安装 本安装对应的OS为安装时默认最小软件包选择。 检查操作系统版本号 官网下载对应的版本(默认社区下载最新发布版本,可在Archives页面下载之前的小版本) 官网RPM安装参考文档...

PeakFang-BOK
2018/11/15
0
0
mysql5.7在centos上安装的完整教程以及相关的“坑”

安装前的准备 Step1: 如果你系统已经有mysql,如一般centos自带mysql5.1系列,那么你需要删除它,先检查一下系统是否自带mysql yum list installed | grep mysql Step2: 删除系统自带的mysql...

lifetragedy
2016/11/25
0
0
centos7下nginx+php7+mysql5.7部署discuz

本文章是个人在搭建discuz论坛时的一个过程,由于本人不是做php开发,则对php不太熟悉,搭建discuz期间花费了不少时间,所以记录下来,供大家参考。 搭建discuz是在Centos7系统上,采用nginx...

Calon
2017/11/27
0
0
CentOS7安装配置启动MySQL(附解决password does not satisfy)

部分内容借鉴自 https://www.linuxidc.com/Linux/2016-09/135288.htm https://www.cnblogs.com/ivictor/p/5142809.html 安装环境:CentOS7 64位 MINI版,安装MySQL5.7 1、配置YUM源 在MySQL......

临江仙卜算子
2018/04/16
0
0
如何用CentOS7安装MySQL5.7(RPM安装)

一、 MySQL 5.7 主要特性: 原生支持 Systemd 更好的性能:对于多核 CPU 、固态硬盘、锁有着更好的优化 更好的 InnoDB 存储引擎 更为健壮的复制功能:复制带来了数据完全不丢失的方案,传统金...

Mr_leolee
2017/05/19
0
0

没有更多内容

加载失败,请刷新页面

加载更多

Redis之父表示ARM服务器没戏!

ARM表示Neoverse N1平台和E1 CPU即将发布,Neoverse N1和E1采用7nm制程,并且为服务器和通信设备增加重要提升,拥有高可扩展性、高处理量以及高性能,将分别在2020年和2021年投入使用。 与C...

linuxCool
18分钟前
2
0
YARN 内存参数终极详解

YARN环境中应用程序JAR包冲突问题的分析及解决 Hadoop框架自身集成了很多第三方的JAR包库。Hadoop框架自身启动或者在运行用户的MapReduce等应用程序时,会优先查找Hadoop预置的JAR包。这样的...

stys35
23分钟前
0
0
Mybatis常用总结一

这一节的学习强烈建议实际操作 主键自增和自定义主键 实现描述:我们在写程序时,时常会遇到这样的问题:插入一条数据,但因有主键的存在,而有时候会报“违反唯一性约束”的错误,我们可以使...

大笨象会跳舞吧
23分钟前
0
0
计数二进制子串

leetcode:https://leetcode.com/problems/count-binary-substrings/ 给定一个字符串 s,计算具有相同数量0和1的非空(连续)子字符串的数量,并且这些子字符串中的所有0和所有1都是组合在一起...

woshixin
26分钟前
0
0
mysql utf8mb4字符集,存储emoji表情

字符集utf8mb4 utf8mb4兼容utf8,且比utf8能表示更多的字符。 看unicode编码区 从1 ~ 126就属于传统utf8区,当然utf8mb4也兼容这个区,126行以下就是utf8mb4扩充区,什么时候你需要存储那些...

我心中有猛狗
29分钟前
0
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部