MySQL安全配置向导mysql_secure_installation详解

所属分类: 数据库 / Mysql 阅读数: 120
收藏 0 赞 0 分享

安装完mysql-server 会提示可以运行mysql_secure_installation。运行mysql_secure_installation会执行几个设置:
  a)为root用户设置密码
  b)删除匿名账号
  c)取消root用户远程登录
  d)删除test库和对test库的访问权限
  e)刷新授权表使修改生效

通过这几项的设置能够提高mysql库的安全。建议生产环境中mysql安装这完成后一定要运行一次mysql_secure_installation,详细步骤请参看下面的命令:

复制代码 代码如下:

[root@server1 ~]# mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
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 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.
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
before moving into a production environment.
Remove test database and access to it? [Y/n] <– 是否删除test数据库,直接回车
- 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…
All done! If you've completed all of the above steps, your MySQL
installation should now be secure.
Thanks for using MySQL!
[root@server1 ~]#

更多精彩内容其他人还在看

mysql服务1067错误多种解决方案分享

今天我的mysql服务器突然出来了1067错误提示,无法正常启动了,我今天从网上找寻了大量的解决mysql服务1067错误的办法,有需要的朋友可以看看
收藏 0 赞 0 分享

深入Mysql字符集设置分析

深入Mysql字符集设置分析,使用mysql的朋友可以参考下
收藏 0 赞 0 分享

MySql 备忘录

在MySQL中如果不为NOT NULL字段赋值(等同于赋NULL值)也就是说,MySQL中NOT NULL并不是一个约束条件了
收藏 0 赞 0 分享

利用mysql的inet_aton()和inet_ntoa()函数存储IP地址的方法分享

当前很多应用都适用字符串char(15)来存储IP地址(占用16个字节),利用inet_aton()和inet_ntoa()函数,来存储IP地址效率很高,适用unsigned int 就可以满足需求,不需要使用bigint,只需要4个字节,节省存储空间,同时效率也高很多
收藏 0 赞 0 分享

IP处理函数inet_aton()和inet_ntoa()使用说明

IP处理函数inet_aton()和inet_ntoa()使用说明,需要的朋友可以参考下
收藏 0 赞 0 分享

mysql数据库互为主从配置方法分享

共有四台机器:A(10.1.10.28),B(10.1.10.29),C(10.1.10.30),D(10.1.10.31)。配置后结果:A-C互为主从,B为A的slave,D为C的slave
收藏 0 赞 0 分享

Mysql中校对集utf8_unicode_ci与utf8_general_ci的区别说明

一直对utf8_unicode_ci与utf8_general_ci这2个校对集很迷惑,今天查了手册有了点眉目。不过对中文字符集来说采用utf8_unicode_ci与utf8_general_ci时有何区别还是不清楚
收藏 0 赞 0 分享

对于mysql的query_cache认识的误区

一直以来,对于mysql的query_cache,在网上就流行着这样的说法,对于mysql的query_cache键值就是mysql的query,所以,如果在query中有任何的不同,包括多了个空格,都会导致mysql认为是不同的查询
收藏 0 赞 0 分享

MySQL InnoDB之事务与锁详解

MySQL InnoDB之事务与锁详解,需要使用事务的朋友可以参考下
收藏 0 赞 0 分享

mysql中迅速插入百万条测试数据的方法

最近想到创建一个大量数据的测试环境,于是找了一下怎么插入100W条数据,我用的是20个字段
收藏 0 赞 0 分享
查看更多