发布网友 发布时间:2022-04-20 20:33
共1个回答
热心网友 时间:2022-04-10 02:02
安装完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_installationNOTE:RUNNINGALLPARTSOFTHISSCRIPTISRECOMMENDEDFORALLMySQLSERVERSINPRODUCTIONUSE!PLEASEREADEACHSTEPCAREFULLY!InordertologintoMySQLtosecureit,we'llneedthecurrentpasswordfortherootuser.Ifyou'vejustinstalledMySQL,andyouhaven'tsettherootpasswordyet,thepasswordwillbeblank,soyoushouldjustpressenterhere.Entercurrentpasswordforroot(enterfornone):<–初次运行直接回车OK,successfullyusedpassword,movingon…SettingtherootpasswordensuresthatnobodycanlogintotheMySQLrootuserwithouttheproperauthorisation.Setrootpassword?[Y/n]<–是否设置root用户密码,输入y并回车或直接回车Newpassword:<–设置root用户的密码Re-enternewpassword:<–再输入一次你设置的密码Passworpdatedsuccessfully!Reloadingprivilegetables..…Success!Bydefault,aMySQLinstallationhasananonymoususer,allowinganyonetologintoMySQLwithouthavingtohaveauseraccountcreatedforthem.Thisisintendedonlyfortesting,andtomaketheinstallationgoabitsmoother.Youshouldremovethembeforemovingintoaproctionenvironment.Removeanonymoususers?[Y/n]<–是否删除匿名用户,生产环境建议删除,所以直接回车…Success!Normally,rootshouldonlybeallowedtoconnectfrom'localhost'.Thisensuresthatsomeonecannotguessattherootpasswordfromthenetwork.Disallowrootloginremotely?[Y/n]<–是否禁止root远程登录,根据自己的需求选择Y/n并回车,建议禁止…Success!Bydefault,MySQLcomeswithadatabasenamed'test'thatanyonecanaccess.Thisisalsointendedonlyfortesting,andshouldberemovedbeforemovingintoaproctionenvironment.Removetestdatabaseandaccesstoit?[Y/n]<–是否删除test数据库,直接回车-Droppingtestdatabase……Success!