mysql_secure_installation - Improve MySQL Installation Security


What is mysql_secure_installation?

Let us understand the MySQL installation related program mysql_secure_installation −

  • This program enables the user to improve the security of their MySQL installation in the below mentioned ways:

  • The user can set a password for root accounts.

  • The user can remove root accounts which are accessible from outside the local host.

  • The user can remove anonymous-user accounts.

  • The user can remove the test database which, by default, can be accessed by all users, even anonymous users), and privileges that permit anyone to access databases with names that start with test_.

  • The mysql_secure_installation helps the user to implement security recommendations.

Normal usage is to connect to the local MySQL server, then invoke mysql_secure_installation without arguments. The example has been shown below −

shell> mysql_secure_installation

When the above statement is executed, mysql_secure_installation prompts the user to determine which actions need to be performed.

Connect to local server

Most of the usual MySQL client options like --host and --port can be used on the command line and in the option files. Let us take an example −

To connect to the local server over IPv6 using port 3307, the below command can be used −

shell> mysql_secure_installation --host=::1 --port=3307

Options

The mysql_secure_installation supports the below options and can be specified on the command line or in the [mysql_secure_installation] and [client] groups of an option file.

--host=host_name, -h host_name

It helps connect to the MySQL server on the given host.

--no-defaults

It doesn’t read any option files. If program startup fails due to reading unknown options from an option file, --no-defaults option can be used to prevent them from being read.

--help, -?

It helps display a help message and exit.

--use-default

It is used to execute noninteractively. This option can be used for unattended installation operations.

--user=user_name, -u user_name

It is the user name of the MySQL account to be used to connect to the server.

Updated on: 10-Mar-2021

334 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements