MySQL Secure Installation
mysql_secure_installation is basically used to improve the security of the mysql server installation.
Key benefits:
- Prevent unauthorised access to the database server by setting strong password for the root user.
- It also helps in removing anonymous users and disallowing remote root login.
Now we will look at the steps to safely secure your mysql server:
Step 1: First check the path where mysql_secure_installation is present
which mysql_secure_installation You can also check out the file permission by :
ls -ltr /usr/bin/mysql_secure_installationStep 2 : Next we will get the temporary password for our root account
sudo grep password /var/log/mysqld.logStep 3 : Now we will execute the command of mysql_secure_installation
mysql_secure_installation First you will need to enter your temporary password, then you will be prompted to enter the new password (Make sure to use a strong password)
You may be asked again to enter new password, if your password does not satisfy the current policy requirements.
Error will get displayed like this:
Step 4: After entering your password, you will be shown the password strength.
After pressing Enter, you will be asked to change the the password of the root, enter : N
Remove Anonymous users, enter : Y
Disallow root login remotely, enter : Y
Remove test database and access to it, enter : Y
Reload privilege tables now, enter : Y
Great! You have successfully secured your mysql server with the root password using mysql_secure_installation script 🎉
Now, to check, let's log in to MySQL by entering the following command:
mysql --host=localhost --user=root --password
After pressing enter, you will be prompted to enter the password you just created using mysql_secure_installation.
If you see something like this, you have successfully logged in to your mysql account 🎉



Comments
Post a Comment