zl程序教程

您现在的位置是:首页 >  数据库

当前栏目

MySQL安全配置向导mysql_secure_installation详解

mysql配置安全 详解 Secure 向导 installation
2023-06-13 09:15:19 时间

安装完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:RUNNINGALLPARTSOFTHISSCRIPTISRECOMMENDEDFORALLMySQL
SERVERSINPRODUCTIONUSE!PLEASEREADEACHSTEPCAREFULLY!
InordertologintoMySQLtosecureit,we"llneedthecurrent
passwordfortherootuser.Ifyou"vejustinstalledMySQL,and
youhaven"tsettherootpasswordyet,thepasswordwillbeblank,
soyoushouldjustpressenterhere.
Entercurrentpasswordforroot(enterfornone):<?初次运行直接回车
OK,successfullyusedpassword,movingon…
SettingtherootpasswordensuresthatnobodycanlogintotheMySQL
rootuserwithouttheproperauthorisation.
Setrootpassword?[Y/n]<?是否设置root用户密码,输入y并回车或直接回车
Newpassword:<?设置root用户的密码
Re-enternewpassword:<?再输入一次你设置的密码
Passwordupdatedsuccessfully!
Reloadingprivilegetables..
…Success!
Bydefault,aMySQLinstallationhasananonymoususer,allowinganyone
tologintoMySQLwithouthavingtohaveauseraccountcreatedfor
them.Thisisintendedonlyfortesting,andtomaketheinstallation
goabitsmoother.Youshouldremovethembeforemovingintoa
productionenvironment.
Removeanonymoususers?[Y/n]<?是否删除匿名用户,生产环境建议删除,所以直接回车
…Success!
Normally,rootshouldonlybeallowedtoconnectfrom"localhost".This
ensuresthatsomeonecannotguessattherootpasswordfromthenetwork.
Disallowrootloginremotely?[Y/n]<?是否禁止root远程登录,根据自己的需求选择Y/n并回车,建议禁止
…Success!
Bydefault,MySQLcomeswithadatabasenamed"test"thatanyonecan
access.Thisisalsointendedonlyfortesting,andshouldberemoved
beforemovingintoaproductionenvironment.
Removetestdatabaseandaccesstoit?[Y/n]<?是否删除test数据库,直接回车
-Droppingtestdatabase…
…Success!
-Removingprivilegesontestdatabase…
…Success!
Reloadingtheprivilegetableswillensurethatallchangesmadesofar
willtakeeffectimmediately.
Reloadprivilegetablesnow?[Y/n]<?是否重新加载权限表,直接回车
…Success!
Cleaningup…
Alldone!Ifyou"vecompletedalloftheabovesteps,yourMySQL
installationshouldnowbesecure.
ThanksforusingMySQL!
[root@server1~]#