mysql_secure_installation命令我是这样设置的

文章概述
这篇文章介绍了MySQL安装后使用的mysql_secure_installation命令,该命令需要进行一系列选项的设置来确保数据库的安全性。其中包括设置root用户密码、切换使用unix_socket通信方法、删除匿名用户、关闭root远程登陆、删除测试数据库等。建议在生产环境中运行所有步骤来确保数据库的安全性。
关键要点
1.mysql_secure_installation是Mariadb数据库安装后的安全设置过程。
2.设置root密码和禁止匿名用户等措施可以提高安全性。
3.删除测试数据库和其他不必要的权限也是安全设置的一部分。
4.完成所有步骤后,Mariadb安装应该更加安全可靠。
介绍
这篇文字大概讲解 mysql_secure_installation 的各个选项的设置。mysql_secure_installation 是 Mariadb 数据库安装结束后需要进行的一个过程,就像应用程序安装后需要配置一样。
$ sudo mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
haven't set the root password yet, you should just press enter here.
Enter current password for root (enter for none):
OK, successfully used password, moving on...
Setting the root password or using the unix_socket ensures that nobody
can log into the MariaDB root user without the proper authorisation.
You already have your root account protected, so you can safely answer 'n'.
Switch to unix_socket authentication [Y/n] n
Enabled successfully!
Reloading privilege tables..
... Success!
You already have your root account protected, so you can safely answer 'n'.
Change the root password? [Y/n] Y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success!
By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB 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] Y
... 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] Y
... Success!
By default, MariaDB 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] Y
- 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] Y
... Success!
Cleaning up...
All done! If you've completed all of the above steps, your MariaDB
installation should now be secure.
Thanks for using MariaDB!
在Enter current password for root (enter for none):
新安装没有设置root密码,所以在这里直接按回车键。
在Switch to unix_socket authentication [Y/n]
这是切换使用socket通信方法,我输入: n。
在Change the root password? [Y/n]
修改root密码,输入:y
在New password
输入你定义的密码,比如:123456*
在Re-enter new password
再次收入密码,123456*
在Remove anonymous users? [Y/n]
这是删除匿名用户,输入:Y
在Disallow root login remotely? [Y/n]
关闭root远程登陆,输入:Y
在Remove test database and access to it? [Y/n]
删除测试数据库,输入:Y
在Reload privilege tables now? [Y/n]
重新加载特权表,这个表保存用户特权信息,输入:Y