大佬教程收集整理的这篇文章主要介绍了centos7.1上安装Mysql5.7.23,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
2018-09-05
8月底看到百度云做活动,30块钱半年我就买了一个,一开始我安装的是MysqL5.6.22,结果百度云给我提示说高危漏洞让我把 MysqL最起码升级到5.7.23,下面就是安装的过程了。
下载MysqL:
1、下载MysqL:https://dev.MysqL.com/downloads/MysqL/5.7.html#download
2、网页需要向下滚一丢丢才能看到下载按钮,记得第一次来的时候以为必须要注册才可以下载,o(︶︿︶)o 唉
3、(1)选择 1 的话,使用命令下载:
[[email protected] ~]# wget https://dev.MysqL.com/get/Downloads/MysqL-5.7/MysqL-5.7.23-1.el7.x86_64.rpm-bundle.tar
(2)选择 2 的话,下载后用XsHell等远程连接工具放到linux上去
准备:
下载的过程别闲着,再开一个窗口来配置一下环境
1、 检测是否已经安装了MysqL,使用下面命令查看
[[email protected] ~]# rpm -qa | grep MysqL
如果已经安装了,将其卸载,如:
[[email protected] ~]# rpm -e --nodeps MysqL-libs-5.1.71-1.el6.x86_64
2、查看一下 centos7自带的MariaDB数据库是否存在
[[email protected] ~]# rpm -qa | grep -i mariadb @H_618_119@mariadb-libs-5.5.56-2.el7.x86_64
安装MysqL的时候可能会和MariaDB有冲突,所以需要将它干掉
[[email protected] ~]# rpm -e --nodeps mariadb-libs-5.5.56-2.el7.x86_64
3、MysqL的server端需要perl支持,所以安装一下
[[email protected] ~]# yum install perl -y
4、MysqL包应该下好了吧。。。先把压缩包复制到自己建的目录下,再解压一下会有12个rpm包
[[email protected] ~]# mkdir /usr/local/@H_616_151@MysqL [[email protected] ~]# cd /usr/local/@H_616_151@MysqL [[email protected] MysqL]# cp /root/MysqL-5.7.23-1.el7.x86_64.rpm-bundle.tar /usr/local/@H_616_151@MysqL [[email protected] MysqL]# tar -xvf MysqL-5.7.23-1.el7.x86_64.rpm-bundle.tar
[[email protected] MysqL]# ls@H_618_119@ MysqL-community-client-5.7.23-1.el7.x86_64.rpm@H_618_119@ MysqL-community-common-5.7.23-1.el7.x86_64.rpm@H_618_119@ MysqL-community-devel-5.7.23-1.el7.x86_64.rpm@H_618_119@ MysqL-community-embedded-5.7.23-1.el7.x86_64.rpm@H_618_119@ MysqL-community-embedded-compat-5.7.23-1.el7.x86_64.rpm@H_618_119@ MysqL-community-embedded-devel-5.7.23-1.el7.x86_64.rpm@H_618_119@ MysqL-community-libs-5.7.23-1.el7.x86_64.rpm@H_618_119@ MysqL-community-libs-compat-5.7.23-1.el7.x86_64.rpm@H_618_119@ MysqL-community-minimal-debuginfo-5.7.23-1.el7.x86_64.rpm@H_618_119@ MysqL-community-server-5.7.23-1.el7.x86_64.rpm@H_618_119@ MysqL-community-server-minimal-5.7.23-1.el7.x86_64.rpm@H_618_119@ MysqL-community-test-5.7.23-1.el7.x86_64.rpm
安装:
环境什么的都OK了之后就开始安装了:
因为解压出的这些rpm包之间有相互依赖的关系(gay里gay气的)所以要按照顺序去一个一个的安装
@H_616_151@[[email protected] MysqL]# rpm -ivh MysqL-community-common-5.7.23-1@H_616_151@.el7.x86_64.rpm
[[email protected] MysqL]# rpm -ivh MysqL-community-libs-5.7.23-1.el7.x86_64.rpm@H_618_119@[[email protected] MysqL]# rpm -ivh MysqL-community-client-5.7.23-1.el7.x86_64.rpm@H_618_119@[[email protected] MysqL]# rpm -ivh MysqL-community-server-5.7.23-1.el7.x86_64.rpm
安装前两个都好好的,后面第三个安装的时候报错了
[[email protected] MysqL]# rpm -ivh MysqL-community-client-5.7.23-1.el7.x86_64.rpm@H_618_119@warning: MysqL-community-client-5.7.23-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature,key ID 5072e1f5: NOKEY@H_618_119@error: @L_607_74@ dependencies:@H_618_119@MysqL-community-libs(x86-64) >= 5.7.9 is needed by MysqL-community-client-5.7.23-1.el7.x86_64
解决方法是在命令后面增加 2 个参数( --nodeps --force )来破坏他们之间的依赖关系
[[email protected] MysqL]# rpm -ivh MysqL-community-client-5.7.23-1.el7.x86_64.rpm --nodeps --@H_616_151@force@H_618_119@warning: MysqL-community-client-5.7.23-1.el7.x86_64.rpm: Header V3 DSA/@H_616_151@SHA1 Signature,key ID 5072e1f5: NOKEY@H_618_119@Preparing... ################################# [100%@H_616_151@] updating /@H_616_151@ installing... 1:MysqL-community-client-5.7.23-1.e################################# [100%@H_616_151@]
[[email protected] MysqL]# rpm -ivh MysqL-community-server-5.7.23-1@H_616_151@.el7.x86_64.rpm warning: MysqL-community-server-5.7.23-1.el7.x86_64.rpm: Header V3 DSA/@H_616_151@SHA1 Signature,key ID 5072e1f5: NOKEY@H_618_119@Preparing... ################################# [100%@H_616_151@] updating /@H_616_151@ installing... 1:MysqL-community-server-5.7.23-1.e################################# [100%]
初始化:
[[email protected] MysqL]# systemctl start MysqLd.service
启动MysqL服务
[[email protected] MysqL]# service MysqLd start
这时候如果想登陆,是不知道密码的,所以需要查看一下初始密码
[[email protected] MysqL]# cat /var/log/@H_616_151@MysqLd.log
使用这个初始密码进行登陆,然后把密码改一下
[[email protected] MysqL]# MysqL -u root -@H_616_151@p Enter password:@H_618_119@MysqL> set password = password(‘密码密码密码‘);@H_618_119@Query OK,0 rows affected,1 warning (0.00 seC)
为了方便以后使用sqlyog等数据库软件远程连接,需要开启外部远程访问权限
MysqL> grant all privileges on *.* to ‘root‘ @‘%‘ identified by ‘密码密码密码!‘@H_616_151@; Query OK,0 rows affected,1 warning (0.00 seC)
再立即刷新一下
MysqL>@H_616_151@ flush privileges; Query OK,0 rows affected (0.01 seC)@H_618_119@MysqL> exit;@H_618_119@Bye
这时候如果使用远程数据库软件进行连接还是会失败,因为没有开启3306端口,来开启一下
[[email protected] MysqL]# /sbin/iptables -I INPUT -p tcp --dport 3306 -j ACCEPT
在保存本次更改的时候出错了
[[email protected]]# /etc/rc.d/init.d/@H_616_151@iptables save -bash: /etc/rc.d/init.d/iptables: No such file or directory
这是因为防火墙没开,查看一下,还真是防火墙没开
@H_616_151@[[email protected] MysqL]# systemctl status firewalld ● firewalld.service - firewalld -@H_616_151@ dynamic firewall daemon Loaded: loaded (/usr/lib/systemd/system/@H_616_151@firewalld.service; disabled; vendor preset: enabled) Active: inactive (dead)
再来开启一下防火墙
@H_616_151@[[email protected] MysqL]# systemctl start firewalld [[email protected] MysqL]# systemctl status firewalld ● firewalld.service - firewalld -@H_616_151@ dynamic firewall daemon Loaded: loaded (/usr/lib/systemd/system/@H_616_151@firewalld.service; disabled; vendor preset: enabled) Active: active (running) since Wed 2018-09-05 19:05:13@H_616_151@ CST; 7s ago Main PID: 33978@H_616_151@ (firewalld) CGroup: /system.slice/@H_616_151@firewalld.service └─33978 /usr/bin/python -Es /usr/sbin/firewalld --nofork --@H_616_151@nopid Sep 05 19:05:12 instance-6z7m60u3 systemd[1]: StarTing firewalld -@H_616_151@ dynamic firewall daemon... Sep 05 19:05:13 instance-6z7m60u3 systemd[1]: Started firewalld - dynamic firewall daemon.
防火墙开启成功后,接着开启3306端口,并且再刷新一下防火墙
[[email protected] MysqL]# firewall-cmd --zone=public --add-port=3306/tcp --@H_616_151@peRMANent success [[email protected] MysqL]# firewall-cmd --@H_616_151@reload success
使用Navicat测试连接一下,连接成功了!
以上是大佬教程为你收集整理的centos7.1上安装Mysql5.7.23全部内容,希望文章能够帮你解决centos7.1上安装Mysql5.7.23所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。