安裝完mysql-server 會提示可以執行mysql_secure_installation。執行mysql_secure_installation會執行以下幾個設定:
- 為root使用者設定密碼
- 取消root使用者遠端登入
- 重新整理授權表使修改生效
透過以上幾項設定能夠提高mysql庫的安全。建議生產環境中mysql安裝這完成後一定要執行一次mysql_secure_installation,相關操作如下:
[root@localhost ~]# mysql_secure_installationNOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQLSERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!In order to log into MySQL to secure it, we'll need the currentpassword for the root user. If you've just installed MySQL, andyou 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 MySQLroot 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 anyoneto log into MySQL without having to have a user account created forthem. This is intended only for testing, and to make the installationgo a bit smoother. You should remove them before moving into aproduction environment.Remove anonymous users? [Y/n] //是否刪除匿名使用者,生產環境建議刪除,所以直接回車… Success!Normally, root should only be allowed to connect from 'localhost'. Thisensures 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 canaccess. This is also intended only for testing, and should be removedbefore 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 farwill take effect immediately.Reload privilege tables now? [Y/n] //是否重新載入許可權表,直接回車… Success!Cleaning up…All done! If you've completed all of the above steps, your MySQLinstallation should now be secure.Thanks for using MySQL!
如果你覺得這篇文章還不錯,就請動動你的發財手為本文點贊-評論-轉發吧,因為這將是我持續輸出更多優質文章的最強動力,謝謝!
最新評論