参考:https://www.cnblogs.com/jimboi/p/6405560.html
1.下载rpm文件
wget https://dev.MysqL.com/get/MysqL57-community-release-el6-9.noarch.rpm
[[email protected] /]# wget https://dev.MysqL.com/get/MysqL57-community-release-el6-9.noarch.rpm--2019-01-02 18:11:58-- https://dev.MysqL.com/get/MysqL57-community-release-el6-9.noarch.rpm 正在解析主机 dev.MysqL.com... 137.254.60.11 正在连接 dev.MysqL.com|137.254.60.11|:443... 已连接。 已发出 http 请求,正在等待回应... 302 Found 位置:https://repo.MysqL.com//MysqL57-community-release-el6-9.noarch.rpm [跟随至新的 URL] --2019-01-02 18:12:03-- https://repo.MysqL.com//MysqL57-community-release-el6-9.noarch.rpm 正在解析主机 repo.MysqL.com... 23.76.232.185 正在连接 repo.MysqL.com|23.76.232.185|:443... 已连接。 已发出 http 请求,正在等待回应... 200 OK 长度:9216 (9.0K) [application/x-redhat-package-@H_419_41@manager] 正在保存至: “MysqL57-community-release-el6-9.noarch.rpm” 100%[===================================================>] 9,216 --.-K/s in 0s 2019-01-02 18:12:04 (52.9 MB/s) - 已保存 “MysqL57-community-release-el6-9.noarch.rpm” [9216/9216])
2.安装rpm包
rpm -Uvh MysqL57-community-release-el6-9.noarch.rpm
[[email protected] /]# rpm -Uvh MysqL57-community-release-el6-9.noarch.rpm warning: MysqL57-community-release-el6-9.noarch.rpm: Header V3 DSA/SHA1 Signature,key ID 5072e1f5: NOKEY Preparing... ########################################### [100%] 1:MysqL57-community-relea########################################### [100%]
安装成功后,会在/etc/yum.repos.d/下面多几个MysqL的包
[[email protected] /]# cd /etc/yum.repos.d/ [[email protected] yum.repos.d]# ll 总用量 40 -rw-r--r--. 1 root root 1991 5月 19 2016 CentOS-Base.repo -rw-r--r--. 1 root root 647 5月 19 2016 CentOS-Debuginfo.repo -rw-r--r--. 1 root root 289 5月 19 2016 CentOS-fasttrack.repo -rw-r--r--. 1 root root 630 5月 19 2016 CentOS-@H_419_41@media.repo -rw-r--r--. 1 root root 6259 5月 19 2016 CentOS-Vault.repo -rw-r--r--. 1 root root 957 11月 5 2012 epel.repo -rw-r--r--. 1 root root 1056 11月 5 2012 epel-tesTing.repo -rw-r--r--. 1 root root 1414 9月 12 2016 MysqL-community.repo -rw-r--r--. 1 root root 1440 9月 12 2016 MysqL-community-source.repo
3.安装MysqL (此过程需要时间)
yum install MysqL-community-server
[[email protected] /]# yum install MysqL-community-server 已加载插件:fastestmirror,refresh-packagekit,security 设置安装进程 Loading mirror speeds from cached hostfile epel/Metalink | 7.5 kB 00:00 * base: mirrors.cqu.edu.cn * epel: mirrors.huaweicloud.com * extras: mirror.bit.edu.cn * updates: mirrors.zju.edu.cn base | 3.7 kB 00:00 epel | 3.2 kB 00:00 epel/priMary | 3.2 MB 00:02 epel 12507/12507 extras | 3.4 kB 00:00 MysqL-connectors-community | 2.5 kB 00:00 MysqL-connectors-community/priMary_db | 27 kB 00:00 MysqL-tools-community | 2.5 kB 00:00 MysqL-tools-community/priMary_db | 45 kB 00:00 MysqL57-community | 2.5 kB 00:00 MysqL57-community/priMary_db | 164 kB 00:00 updates | 3.4 kB 00:00 解决依赖关系 --> 执行事务检查 ---> Package MysqL-community-server.x86_64 0:5.7.24-1.el6 will be 安装 --> 处理依赖关系 MysqL-community-common(x86-64) = 5.7.24-1.el6,它被软件包 MysqL-community-server-5.7.24-1.el6.x86_64 需要 --> 处理依赖关系 MysqL-community-client(x86-64) >= 5.7.9,它被软件包 MysqL-community-server-5.7.24-1.el6.x86_64 需要 --> 执行事务检查 ---> Package MysqL-community-client.x86_64 0:5.7.24-1.el6 will be 安装 --> 处理依赖关系 MysqL-community-libs(x86-64) >= 5.7.9,它被软件包 MysqL-community-client-5.7.24-1.el6.x86_64 需要 ---> Package MysqL-community-common.x86_64 0:5.7.24-1.el6 will be 安装 --> 执行事务检查 ---> Package MysqL-community-libs.x86_64 0:5.7.24-1.el6 will be obsoleTing ---> Package MysqL-libs.x86_64 0:5.1.73-7.el6 will be 取代 --> 处理依赖关系 libMysqLclient.so.16()(64bit),它被软件包 2:postfix-2.6.6-6.el6_7.1.x86_64 需要 --> 处理依赖关系 libMysqLclient.so.16(libMysqLclient_16)(64bit),它被软件包 2:postfix-2.6.6-6.el6_7.1.x86_64 需要 --> 执行事务检查 ---> Package MysqL-community-libs-compat.x86_64 0:5.7.24-1.el6 will be obsoleTing ---> Package postfix.x86_64 2:2.6.6-6.el6_7.1 will be 升级 ---> Package postfix.x86_64 2:2.6.6-8.el6 will be an update --> 完成依赖关系计算 依赖关系解决 ============================================================================================= 软件包 架构 版本 仓库 大小 ============================================================================================= 正在安装: MysqL-community-libs x86_64 5.7.24-1.el6 MysqL57-community 2.1 M replacing MysqL-libs.x86_64 5.1.73-7.el6 MysqL-community-libs-compat x86_64 5.7.24-1.el6 MysqL57-community 1.6 M replacing MysqL-libs.x86_64 5.1.73-7.el6 MysqL-community-server x86_64 5.7.24-1.el6 MysqL57-community 153 M 为依赖而安装: MysqL-community-client x86_64 5.7.24-1.el6 MysqL57-community 23 M MysqL-community-common x86_64 5.7.24-1.el6 MysqL57-community 332 k 为依赖而更新: postfix x86_64 2:2.6.6-8.el6 base 2.0 M 事务概要 ============================================================================================= Install 5 Package(s) Upgrade 1 Package(s) 总下载量:182 M 确定吗?[y/N]:y 下载软件包: (1/6): MysqL-community-client-5.7.24-1.el6.x86_64.rpm | 23 MB 00:42 (2/6): MysqL-community-common-5.7.24-1.el6.x86_64.rpm | 332 kB 00:00 (3/6): MysqL-community-libs-5.7.24-1.el6.x86_64.rpm | 2.1 MB 00:03 (4/6): MysqL-community-libs-compat-5.7.24-1.el6.x86_64.rpm | 1.6 MB 00:02 (5/6): MysqL-community-server-5.7.24-1.el6.x86_64.rpm | 153 MB 04:41 (6/6): postfix-2.6.6-8.el6.x86_64.rpm | 2.0 MB 00:01 --------------------------------------------------------------------------------------------- 总计 559 kB/s | 182 MB 05:33 warning: rpmts_HdrFromFdno: Header V3 DSA/SHA1 Signature,key ID 5072e1f5: NOKEY Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-MysqL ImporTing GPG key 0x5072E1F5: Userid : MysqL Release ENGIneering <[email protected]> Package: MysqL57-community-release-el6-9.noarch (installed) From : /etc/pki/rpm-gpg/RPM-GPG-KEY-MysqL 确定吗?[y/N]:y 运行 rpm_check_debug 执行事务测试 事务测试成功 执行事务 Warning: RPMDB altered outside of yum. 正在安装 : MysqL-community-common-5.7.24-1.el6.x86_64 1/8 正在安装 : MysqL-community-libs-5.7.24-1.el6.x86_64 2/8 正在安装 : MysqL-community-client-5.7.24-1.el6.x86_64 3/8 正在安装 : MysqL-community-libs-compat-5.7.24-1.el6.x86_64 4/8 正在升级 : 2:postfix-2.6.6-8.el6.x86_64 5/8 正在安装 : MysqL-community-server-5.7.24-1.el6.x86_64 6/8 清理 : 2:postfix-2.6.6-6.el6_7.1.x86_64 7/8 正在删除 : MysqL-libs-5.1.73-7.el6.x86_64 8/8 Verifying : 2:postfix-2.6.6-8.el6.x86_64 1/8 Verifying : MysqL-community-common-5.7.24-1.el6.x86_64 2/8 Verifying : MysqL-community-server-5.7.24-1.el6.x86_64 3/8 Verifying : MysqL-community-client-5.7.24-1.el6.x86_64 4/8 Verifying : MysqL-community-libs-compat-5.7.24-1.el6.x86_64 5/8 Verifying : MysqL-community-libs-5.7.24-1.el6.x86_64 6/8 Verifying : MysqL-libs-5.1.73-7.el6.x86_64 7/8 Verifying : 2:postfix-2.6.6-6.el6_7.1.x86_64 8/8 已安装: MysqL-community-libs.x86_64 0:5.7.24-1.el6 MysqL-community-libs-compat.x86_64 0:5.7.24-1.el6 MysqL-community-server.x86_64 0:5.7.24-1.el6 作为依赖被安装: MysqL-community-client.x86_64 0:5.7.24-1.el6 MysqL-community-common.x86_64 0:5.7.24-1.el6 作为依赖被升级: postfix.x86_64 2:2.6.6-8.el6 替代: MysqL-libs.x86_64 0:5.1.73-7.el6 完毕!
4.开启MysqL服务
[[email protected] /]# service MysqLd start 初始化 MysqL 数据库: [失败] [[email protected] /]# service MysqLd start 正在启动 MysqLd: [确定] //正常启动
5.MysqL安装完成会创建临时默认的超级用户,密码存储在/var/log/MysqLd.log,命令查看密码:
grep ‘temporary password‘ /var/log/MysqLd.log
[[email protected] /]# grep ‘temporary password‘ /var/log/MysqLd.log 2019-01-02T10:37:02.765238Z 1 [Note] A temporary password is generated for [email protected]: 7?0?dyl3Uduj (密码)
6.使用默认用户‘root‘@‘localhost‘登录数据库并且修改密码:
[[email protected] /]# MysqL -u root -p
[[email protected] /]# MysqL -u root -p Enter password: (上面的密码) Welcome to the MysqL monitor. Commands end with ; or \g. Your MysqL connection id is 3 Server version: 5.7.24 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.
注意:如果出现错误提示:
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
这个是因为密码过于简单,密码必须符合长度,包含数字、大写小写字母、特殊字符。
7.开启远程连接
1).设置防火墙iptables开放3306接口
在/etc/sysconfig下面有个iptables文件,在倒数第二行添加端口就可以
在控制台输入:
iptables -I INPUT -p tcp --dport 3306 -j ACCEPT
[[email protected] /]# iptables -I INPUT -p tcp --dport 3306 -j ACCEPT
2).然后进行保存:
[[email protected] /]# service iptables save iptables:将防火墙规则保存到 /etc/sysconfig/iptables: [确定]
更新防火墙规则:service iptables restart
删除:iptables -D INPUT -p tcp --dport 3306 -j ACCEPT
@H_301_1194@
8.修改MysqL权限,将localhost修改为%
1).登录MysqL
iptables -D INPUT -p tcp --dport 3306 -j ACCEPT
MysqL -u root -p
2).登录到 MysqL 这个表
MysqL> use MysqL; Reading table information for completion of table and @R_696_8620@n names You can turn off this feature to get a quicker startup with -A Database changed
3)..将root的host修改为%
MysqL> update user set host = ‘%‘ where user =‘root‘; Query OK,1 row affected (0.01 seC) Rows matched: 1 Changed: 1 Warnings: 0
4).重新加载权限
5).输入:
MysqL> SELEct host,user from user where user=‘root‘; +------+------+ | host | user | +------+------+ | % | root | +------+------+ 1 row in set (0.00 seC)
9.Navicat 远程连接
@H_700_1404@
以上是大佬教程为你收集整理的CentOS 中安装 mysql 5.7+全部内容,希望文章能够帮你解决CentOS 中安装 mysql 5.7+所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。