Whenever I used to setup a server, I'd run:
mysql -u root
# Set the root user password for all local domains
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('my_password');
SET PASSWORD FOR 'root'@'localhost.localdomain' = PASSWORD('my_password');
SET PASSWORD FOR 'root'@'127.0.0.1' = PASSWORD('my_password');
# Drop the Any user
DROP USER ''@'localhost';
DROP USER ''@'localhost.localdomain';
# Exit MySQL
exit
Recently I've came across mysql_secure_installation
, which seems to do pretty much the same. Can anyone confirm that I am safe to use mysql_secure_installation
instead of my code?
The purpose is to, well, improve the security of your MySQL installation. I always run mysql_secure_installation right after I fire up MySQL.