How To's

Install and Secure a MySQL Server on CentOS

4,620 views · 0 found this helpful

Was this helpful?

When a MySQL server is first installed, it is not secured properly. Here's how to install and secure a MySQL server.

Install MySQL Server

yum update -y
yum install mysql-server -y

Start MySQL server

service mysqld start
chkconfig mysqld on

Secure MySQL

mysql_secure_installation

You'll be met with the following output

Press return - Default is blank

In order to log into MySQL to secure it, we'll need the current
password for the root user. If you've just installed MySQL, and
you 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):

Answer Yes and enter your new password

Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.

Change the root password? [Y/n] y
New password:

Answer Yes to the rest of the prompts

Remove anonymous users? [Y/n] y
Disallow root login remotely? [Y/n] y
Remove test database and access to it? [Y/n] y
Reload privilege tables now? [Y/n] y

  • Updated

← All articles

Still stuck?

Our engineers answer tickets directly, 24/7.