本文为大家分享了centOS下安装MysqL5.7详细步骤,供大家参考,具体内容如下
原文链接:https://www.jb51.net/article/129348.htm
第一步:
第一句检测系统是否自带安装MysqL,若有执行第二句删除系统自带的MysqL及其依赖。
第二步:
给CentOS添加rpm源,并且选择较新的源,下面代码逐句执行
第三步:
安装MysqL 服务器
1
|
|
第四步:
1
|
service MysqLd start
|
第五步:
查看MysqL是否自启动,并且设置开启自启动
第六步:
这一步很重要!!!
不知道从MysqL哪个版本开始,MysqL的root默认密码就不为空了,在安装的过程中默认密码保存在安装日志中了。我们要通过安装日志找到默认密码,用默认密码登陆MysqL成功后会强行让你修改密码,修改的密码还要够复杂(复合MysqL默认的密码策略)才能修改成功,一般带大小写字母特殊字符和数字超过8个字符就可以。
首先找到安装日志
1
|
find
/ -name MysqLd.log
|
然后发现该日志文件路径在 /var/log/MysqLd.log。然后用下面命令打开,按‘i‘键上翻
1
|
|
上图红色地方就是root密码所在地
第七步:
MysqL安全设置
1
|
MysqL_secure_installation
|
输入上面命令进行下面步骤
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
@H_438_403@
21
22
23
24
25
26
27
28
29
30
31
32
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
you haven‘t
set
the root password yet,the password will be blank,
so you should just press enter here.
OK,successfully used password,moving on…
Setting the root password ensures that nobody can log into the MysqL
root user without the proper authorisation.
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
make
the installation
go a bit smoother. You should remove them before moving into a
production environment.
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.
… Success!
access. This is also intended only
for
testing,and should be removed
before moving into a production environment.
- Dropping
test
database…
… Success!
- Removing privileges on
test
database…
… Success!
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y
/n
] <– 是否重新加载权限表,直接回车
… Success!
Cleaning up…
installation should now be secure.
[[email protected] ~]
#
|
第八步:
可选步骤,原来Linux下的MysqL默认是区分表名大小写的,通过如下设置,可以让MysqL不区分表名大小写:
1、用root登录,修改 /etc/my.cnf;
2、在[MysqLd]节点下,加入一行: lower_case_table_names=1
3、重启MysqL即可; service MysqLd restart
以上就是本文的全部内容,希望对大家的学习有所帮助