CentOS   发布时间:2022-05-09  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了centos安装mysql5.7大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

本文为大家分享了centOS下安装MysqL5.7详细步骤,供大家参,具体内容如下

原文链接:https://www.code.net/article/129348.htm

第一步: 

第一句检测系统是否自带安装MysqL,若有执行第二句删除系统自带的MysqL及其依赖。

1
2
yum list installed | grep @H_897_28@mysqL
yum -y remove MysqL-libs.x86_64

第二步: 

给CentOS添加rpm源,并且选择较新的源,下面代码逐句执行

?
1
2
3
4
5
6
7
wget dev.Mysql.com /get/MysqL-community-release-el6-5 .noarch.rpm
yum localinstall MysqL-community-release-el6-5.noarch.rpm
yum repolist all | grep @H_897_28@mysqL
yum-config-manager --disable MysqL55-community
yum-config-manager --disable MysqL56-community
yum-config-manager -- enable @H_897_28@mysqL57-community-dmr
yum repolist enabled | grep @H_897_28@mysqL

第三步: 

安装MysqL 服务器

?
1
yum install @H_897_28@mysqL-community-server

第四步:

?
1
service MysqLd start

第五步: 

查看MysqL是否自启动,并且设置开启自启动

?
1
2
chkconfig --list | grep @H_897_28@mysqLd
chkconfig MysqLd on

第六步:

这一步很重要!!! 

不知道从MysqL哪个版本开始,MysqL的root默认密码就不为空了,在安装的过程中默认密码保存在安装日志中了。我们要通过安装日志找到默认密码,用默认密码登陆MysqL成功后会强行让你修改密码,修改的密码还要够复杂(复合MysqL默认的密码策略)才能修改成功,一般带大小写字母特殊字符和数字超过8个字符就可以。

首先找到安装日志

?
1
find / -name MysqLd.log

然后发现该日志文件路径在 /var/log/MysqLd.log。然后用下面命令打开,按‘i‘键上翻

?
1
vim /var/log/MysqLd .log

centos安装mysql5.7

上图红色地方就是root密码所在地

第七步: 

@H_91_4@mysqL安全设置

?
1
@H_897_28@mysqL_secure_installation

输入上面命令进行下面步骤

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
@H_995_403@ 21
22
23
24
25
26
27
28
@H_886_419@ 29
30
31
32
@H_419_427@ 33
34
35
36
37
38
39
40
41
42
43
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MysqL to secure it,we‘ll need the current
password for the root user. If you‘ve just installed MysqL,and
you haven‘t set the root password yet,the password will be blank,
so you should just press enter here.
Enter current password for root (enter for nonE):<–初次运行,输入刚刚找到的初始密码,会强制你先修改密码才能进行下去
OK,successfully used password,moving on…
SetTing the root password ensures that nobody can log into the MysqL
root user without the proper authorisation.
Set root password? [Y /n ] <– 是否设置root用户密码,输入y并回车或直接回车
New password: <– 设置root用户的密码
Re-enter new password: <– 再输入一次你设置的密码
password updated successfully!
Reloading privilege tables..
success!
By default,a MysqL installation has an anonymous user,allowing anyone
to log into MysqL without having to have a user account created for
them. This is intended only for tesTing,and to @H_940_30@make the installation
go a bit smoother. You should remove them before moving into a
production environment.
@H_995_403@ Remove anonymous users ? [Y /n ] <– 是否删除匿名用户,生产环境建议删除,所以直接回车
success!
Normally,root should only be allowed to connect from ‘localhost‘ . This
ensures that someone cAnnot guess at the root password from the network.
Disallow root login remotely? [Y /n ] <–是否禁止root远程登录,根据自己的需求选择Y /n 并回车,建议禁止
success!
By default,MysqL comes with a database named ‘test‘ that anyone can
access. This is also intended only for tesTing,and should be removed
@H_886_419@ before moving into a production environment.
Remove test database and access to it? [Y /n ] <– 是否删除 test 数据库,直接回车
- Dropping test database…
success!
@H_419_427@ - Removing privileges on test database…

大佬总结

以上是大佬教程为你收集整理的centos安装mysql5.7全部内容,希望文章能够帮你解决centos安装mysql5.7所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。